Repository navigation
Description
System Info
- TensorRT-LLM main @ e88d19c, PyTorch backend,
TrtllmAttention - Any container or host where the CUDA toolkit is not at
/usr/local/cuda, for example conda/pixi environments.CUDA_HOMEis set, andnvccis onPATH. - Seen on SM107. The code path (trtllm-gen FMHA NVRTC JIT) is not architecture-specific.
Who can help?
Same module as #20507 (fmha/lib/<arch>/libTrtLlmGen.a, the prebuilt trtllm-gen archive). Related: #12612 (trtllm-gen FMHA JIT), #14851 (JIT warmup).
Reproduction
Any configuration where a trtllm-gen FMHA kernel takes the NVRTC path, for example MLA generation. The unit test is enough:
# In a TensorRT-LLM container built from main, as root: move the toolkit away from /usr/local/cuda
mv /usr/local/cuda /usr/local/cuda-real
export CUDA_HOME=/usr/local/cuda-real
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH//\/usr\/local\/cuda/$CUDA_HOME}
which nvcc && nvcc --version | tail -1 # nvcc is found
cd tests/unittest && pytest -q _torch/attention/test_attention_mla.pyResult: 28 failed, 68 passed. Each failure is:
[E] [GenCtx.cpp:68]: Cannot parse NVCC version from /usr/local/cuda/bin/nvcc. Output:
sh: 1: /usr/local/cuda/bin/nvcc: not found
[E] [FmhaInterface.cpp:426]: Error parsing configs: Cannot parse NVCC version from /usr/local/cuda/bin/nvcc. Output:
...
RuntimeError: Error parsing configs: Cannot parse NVCC version from /usr/local/cuda/bin/nvcc.
The printed kernel config has "usesNvRtc": true.
In serving, the same error comes from the trtllm-gen FMHA JIT warmup (Running TRTLLM-Gen FMHA JIT warmup). The first MLA generation warmup step fails on every rank, and executor creation fails with Failed to initialize executor on rank 0: Error parsing configs: Cannot parse NVCC version from /usr/local/cuda/bin/nvcc.
Expected behavior
The JIT uses the toolkit the environment points to (CUDA_HOME, or nvcc on PATH). Better, it does not need nvcc at all when it compiles with NVRTC.
Actual behavior
libTrtLlmGen.a (GenCtx.cpp) runs /usr/local/cuda/bin/nvcc --version and parses release X.Y from the output. That path is the default of the GenCfg nvccPath field, and TensorRT-LLM's generated config (populateJsonConfig in fmha/fmhaKernels.h) does not set it. The version query does not consult CUDA_HOME, CUDA_PATH or PATH: GenCtx.cpp.o in the archive does not call getenv and contains none of those names. This happens with usesNvRtc: true, so it applies even though the kernel is compiled by NVRTC.
I checked what the JIT actually needs from nvcc, on the same test file, with CUDA_HOME set and the toolkit outside /usr/local/cuda in all three runs:
/usr/local/cuda/bin/nvcc |
result |
|---|---|
| absent | 28 failed, 68 passed (140 × nvcc: not found) |
symlink to the real nvcc |
96 passed |
stub that answers only --version (via the real nvcc), logs every call, and fails on anything else |
96 passed; the stub was called once, with --version only |
So nvcc is needed only for the version query. All compilation goes through NVRTC.
Additional notes
Suggested fix, in the trtllm-gen archive (GenCtx), in order of preference:
- When
usesNvRtcis set, take the version from NVRTC (nvrtcVersion, which the archive already references) and do not requirenvcc. - Otherwise resolve
nvccin this order: an explicitnvccPath, then$CUDA_HOME/bin/nvcc, then$CUDA_PATH/bin/nvcc, thennvcconPATH, and only then/usr/local/cuda/bin/nvcc. Report the path that was tried in the error.
Possible TensorRT-LLM-side stopgap until the archive is refreshed: emit "nvccPath" in populateJsonConfig, resolved as in item 2. I have not verified that the archive honors the field when it is set from the generated config; I only see the field name next to its default in the archive's string table.
Workaround for affected environments: provide /usr/local/cuda/bin/nvcc, for example a symlink to the real toolkit.
What is verified: the table above, on SM107 with a build of main at e88d19c in a container whose toolkit is not under /usr/local/cuda. I have not run the "rename /usr/local/cuda" variant in an official image, but it recreates the same condition.
Cross-reference #20507: the serving warmup goes through warmupOneKernel, and the config printed with this error there has "smVersion": "107a". That is the path #20507 describes, which hands Sm107a to the archive without the Sm100f rewrite that run() applies. The unit-test failures above go through run() and print "smVersion": "100f".
Activity
[NVIDIA#20515][fix] Skip nvcc candidates whose status cannot be read