Running GPU Targets with Buck
This skill covers the mechanics of building and running GPU targets
under Buck in fbcode. It is target-agnostic: substitute your own
<buck target> and program arguments.
General requirements
- Run from
fbsource/fbcode.cdtofbsource/fbcodebefore invoking Buck. The@mode/optflags (and other@mode/...files) only resolve when Buck is run from there. - Use
@mode/opt. It provides the core GPU build configuration.@mode/optgenerally sets up the GPU build, but some tritonbench targets still pass-c fbcode.enable_gpu_sections=trueexplicitly — add it if a target's GPU sections fail to build. - Build against the beta Triton with
-m ovr_config//triton:beta. This directory is the beta Triton compiler. Pass this modifier so the target builds and runs against the beta Triton in this tree rather than the default/stable Triton — without it, changes made here are not exercised. - Select the GPU architecture with
-c fbcode.nvcc_arch=<arch>and, where required, the CUDA version with-m ovr_config//third-party/cuda/constraints:<ver>(see Hardware requirements). - Environment variables prefix the
buck2 runand are forwarded to the launched process:<ENV VARS> buck2 run @mode/opt -m ovr_config//triton:beta -c fbcode.nvcc_arch=<arch> [-m ovr_config//third-party/cuda/constraints:<ver>] \ <buck target> -- <program args> buck2 buildvsbuck2 run. Usebuck2 build <target>to compile only (e.g. to surface a compile failure without executing); usebuck2 run <target> -- <args>to build and run. Program arguments go after--.
Hardware requirements
Pick the arch (and CUDA version) for the single GPU you are targeting:
| Hardware | fbcode.nvcc_arch |
ovr_config//third-party/cuda/constraints:<version> |
|---|---|---|
| Hopper (H100) | h100a |
(default) |
| Blackwell B200 / GB200 | b200a |
>= 12.8 |
| Blackwell GB300 | b300a |
>= 13.0 |
Notes:
- B200 / GB200 require CUDA
>= 12.8. Existing tritonbench targets pin12.8; use the version your build expects. - GB300 requires arch
b300aand CUDA>= 13.0. - Set the CUDA version explicitly whenever a minimum applies, since the platform default may be older than the arch requires.
Examples
Blackwell GB300 (b300a, CUDA 13.0), from fbsource/fbcode:
buck2 run @mode/opt -m ovr_config//triton:beta \
-c fbcode.nvcc_arch=b300a \
-m ovr_config//third-party/cuda/constraints:13.0 \
<buck target> -- <program args>
Blackwell B200 / GB200 (b200a, CUDA >= 12.8):
buck2 run @mode/opt -m ovr_config//triton:beta \
-c fbcode.nvcc_arch=b200a \
-m ovr_config//third-party/cuda/constraints:12.8 \
<buck target> -- <program args>
Hopper (h100a):
buck2 run @mode/opt -m ovr_config//triton:beta \
-c fbcode.nvcc_arch=h100a \
<buck target> -- <program args>
With env vars forwarded (e.g. enabling a feature for the run):
SOME_ENV=1 buck2 run @mode/opt -m ovr_config//triton:beta -c fbcode.nvcc_arch=b300a \
-m ovr_config//third-party/cuda/constraints:13.0 \
<buck target> -- <program args>
Compile only (surface a build/compile failure without running):
buck2 build @mode/opt -m ovr_config//triton:beta -c fbcode.nvcc_arch=b300a \
-m ovr_config//third-party/cuda/constraints:13.0 \
<buck target>