facebookresearch / facebookresearch/detectron2
Bug: Detectron2 fails to build with system CUDA 13 + PyTorch 2.9.1
- Dominant language
- Python
- Stars
- 34.7k
- Forks
- 7.9k
- PR merge metrics
- No merged PRs in 30d
Description
## Instructions To Reproduce:
### 1. Full runnable code or full changes you made:
```
# No source modifications.
# Fresh clone of detectron2.
git rev-parse HEAD; git diff
```
### 2. What exact command you run:
```
uv venv --python=3.12 .venv
source .venv/bin/activate
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
uv pip install -e detectron2 --no-build-isolation
```
### 3. Full logs or other relevant observations:
```
/usr/local/cuda/include/crt/host_config.h:143:2: error:
#error -- unsupported GNU version! gcc versions later than 12 are not supported!
nvcc fatal : Host compiler targets unsupported GNU version
W1205 torch/utils/cpp_extension.py: MIG mismatch:
"The detected CUDA version (12.2) has a minor version mismatch with the version that was used to compile PyTorch (12.8)."
error: command '/usr/local/cuda/bin/nvcc' failed with exit code 1
```
Full trace excerpt:
```
In file included from /usr/local/cuda/include/cuda_runtime.h:82:
/usr/local/cuda/include/crt/host_config.h:143:2:
#error -- unsupported GNU version! gcc versions later than 12 are not supported!
...
The detected CUDA version (12.2) has a minor version mismatch with the version that was used to compile PyTorch (12.8)
...
distutils.errors.CompileError: command '/usr/local/cuda/bin/nvcc' failed with exit code 1
```
**Additional observation:**
My system CUDA toolkit is version **13.x**, but PyTorch wheels only ship with CUDA **12.8**, which creates a mismatch. Detectron2 attempts to compile with **system nvcc (CUDA 13)** which rejects **gcc 13**.
### 4. Steps simplified to minimal reproducible example:
No custom datasets or external resources required.
Just:
```
git clone https://github.com/facebookresearch/detectron2
cd detectron2
uv venv --python=3.12 .venv
source .venv/bin/activate
uv pip install torch==2.9.1+cu128 torchvision==0.24.1+cu128 --index-url https://download.pytorch.org/whl/cu128
uv pip install -e . --no-build-isolation
```
This fails consistently on any clean environment with CUDA 13 installed system-wide.
---
## Expected behavior:
Detectron2 should compile its CUDA/C++ extensions successfully, or at least detect and warn when the system CUDA toolkit version (13) is not supported.
Given that PyTorch 2.9.1 supports CUDA 12.8, I expect Detectron2 to either:
* build correctly with CUDA 12.8 (without using system CUDA 13), or
* provide instructions for using PyTorch’s CUDA toolkit instead of system nvcc.
---
## Environment:
(When running the recommended script, replace `` below with your actual output:)
```
wget -nc -q https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py
```
**My known relevant environment details:**
* **GPU:** NVIDIA RTX 4090
* **System CUDA:** 13.x (`/usr/local/cuda`)
* **PyTorch:** 2.9.1+cu128
* **TorchVision:** 0.24.1+cu128
* **Python:** 3.12.11
* **Compiler:** gcc 13.x
* **OS:** Arch Linux
* **Install tool:** `uv`
The script output will confirm this mismatch:
* PyTorch CUDA = 12.8
* System CUDA = 13.x
* gcc > 12 (nvcc from CUDA 13 rejects this)
---
## Additional Notes
I cannot downgrade my system CUDA installation (CUDA 13 is required for other software), and this appears to make Detectron2 impossible to build, because:
* Detectron2 does not yet support CUDA 13
* CUDA 13’s nvcc rejects GCC 13
* PyTorch does not ship CUDA 13 wheels
* Building against system CUDA (13) while PyTorch is built for CUDA 12.8 causes ABI mismatch and build failure
Contributor guide
Assessment
This issue has not been assessed yet.