nvcc fatal : Unsupported gpu architecture 'compute_20'

本文详细介绍了在编译Caffe源代码时遇到的“Unsupported gpu architecture 'compute_20'”错误及其解决方案。该错误通常发生在Makefile.config配置不当的情况下,导致与GPU架构不兼容。文章提供了修改Makefile.config的具体步骤,以确保CUDA版本与GPU架构相匹配,避免编译失败。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误:

VCC src/caffe/layers/softmax_loss_layer.cu
nvcc fatal   : Unsupported gpu architecture 'compute_20'
Makefile:605: recipe for target '.build_release/cuda/src/caffe/layers/softmax_loss_layer.o' failed
make: *** [.build_release/cuda/src/caffe/layers/softmax_loss_layer.o] Error 1

解决方案:

在Makefile.config文件中根据自己CUDA的版本注释不同的行。

# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
# For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.
CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 \
                #-gencode arch=compute_20,code=sm_21
                -gencode arch=compute_30,code=sm_30 \
                -gencode arch=compute_35,code=sm_35 \
                -gencode arch=compute_50,code=sm_50 \
                -gencode arch=compute_52,code=sm_52 \
                -gencode arch=compute_60,code=sm_60 \
                -gencode arch=compute_61,code=sm_61 \
                -gencode arch=compute_61,code=compute_61

### 编译 DCNv2 时遇到 `nvcc` 不支持 GPU 架构 `'compute_86'` 的解决方案 当尝试编译带有特定 CUDA 版本的项目如 DCNv2 并遭遇 `nvcc fatal : Unsupported gpu architecture 'compute_86'` 错误时,这通常意味着当前使用的 NVIDIA 编译器工具链版本不兼容所指定的目标架构。 #### 修改 Makefile 或 CMakeLists.txt 文件 对于此类问题的一个常见修复措施是在项目的构建配置文件中调整目标计算能力设置。具体来说,在 `Makefile` 或者 `CMakeLists.txt` 中找到定义 CUDA 架构的地方,并将其更改为与本地环境相匹配的支持版本: ```makefile CUDA_ARCH := -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_60,code=sm_60 \ -gencode arch=compute_70,code=sm_70 \ -gencode arch=compute_75,code=sm_75 \ -gencode arch=compute_80,code=sm_80 \ -gencode arch=compute_86,code=sm_86 # 移除或注释掉这一行 ``` 如果使用的是较新的 CUDA 工具包,则可能需要移除或修改上述代码片段中的最后一行,因为并非所有的 CUDA 发布版都支持最新的 GPU 架构[^1]。 #### 更新 CUDA 安装路径 另一个潜在的原因可能是由于系统上的 CUDA 路径配置不当引起的。确认 `.bashrc` 和其他 shell 配置文件里关于 CUDA 的环境变量指向了正确的安装位置。例如: ```shell export PATH=/usr/local/cuda-11.0/bin${PATH:+:${PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64\ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} ``` 确保这些路径确实对应于已安装的 CUDA 版本,并且该版本能够识别并处理所需的目标架构[^4]。 #### 使用合适的 PyTorch 及其依赖库版本 考虑到不同版本之间的兼容性差异,建议检查正在使用的 Python、PyTorch 和 CUDA 组合是否相互兼容。特别是对于深度学习框架而言,某些预编译二进制文件可能会针对特定硬件特性进行优化,因此选择适当组合非常重要[^5]。 通过以上方法应该可以有效解决因 `nvcc` 不支持某一代号为 `compute_86` 的 GPU 架构而导致的编译失败问题。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值