本机环境
- Ubuntu16.04
- RTX 2080Ti(算力7.5)
- Cuda9.0.176
- Cudnn7.6.5
- Pytorch1.0.0
问题描述
最近尝试跑插帧的代码DAIN,在安装pytorch扩展的相关依赖时报错:
nvcc fatal : Unsupported gpu architecture 'compute_75'
error: command '/usr/local/cuda-9.0/bin/nvcc' failed with exit status 1
问题分析
从上面报错看是说不支持算力7.5的GPU架构,但是代码readme说可以修改以适配:
但是因为刚上手pytorch,一时半会不知道如何修改设置,
看了github上相关的一些讨论:
- CUDA error trying to run demo following requirements
- Colab compatibility improvements
- Unclear installation description
发现一个网友的解决方案与本人的比较相符,而且参考代码DAIN/my_package/compiler_args.py
文件和Matching CUDA arch and CUDA gencode for various NVIDIA architectures中的描述,Titan RTX和本人的RTX 2080Ti是同一种Turing架构,算力都是7.5。就决定参照着该网友的回答修改setup.py文件中的nvcc_args
:
#!/usr/bin/env python3
import os
import torch
from setuptools import setup,find_packages
from torch.utils.cpp_extension import BuildExtension,CUDAExtension
from compiler_args import nvcc_args,cxx_args
nvcc_args = [ '-gencode', 'arch=compute_75,code=sm_75', '-gencode', 'arch=compute_75,code=compute_75' ]##修改参数 20201206
setup(
name='depthflowprojection_cuda',
ext_modules=[
CUDAExtension('depthflowprojection_cuda', [
'depthflowprojection_cuda.cc',
'depthflowprojection_cuda_kernel.cu'
], extra_compile_args={'cxx': cxx_args, 'nvcc': nvcc_args})
],
cmdclass={
'build_ext': BuildExtension
})
但是运行了还是报错:nvcc fatal : Unsupported gpu architecture 'compute_75'
无奈,只好又google了下:
发现nvcc fatal : Unsupported gpu architecture 'compute_75’中有个老哥的回答也是2080Ti,而且他解决了:
我就按着compute_70的来修改,居然OK了
#!/usr/bin/env python3
import os
import torch
from setuptools import setup,find_packages
from torch.utils.cpp_extension import BuildExtension,CUDAExtension
from compiler_args import nvcc_args,cxx_args
#nvcc_args = [ '-gencode', 'arch=compute_75,code=sm_75', '-gencode', 'arch=compute_75,code=compute_75' ]##修改参数 20201206
nvcc_args = ['--gpu-architecture=compute_70','--gpu-code=sm_70' ]##修改参数 20201207
setup(
name='depthflowprojection_cuda',
ext_modules=[
CUDAExtension('depthflowprojection_cuda', [
'depthflowprojection_cuda.cc',
'depthflowprojection_cuda_kernel.cu'
], extra_compile_args={'cxx': cxx_args, 'nvcc': nvcc_args})
],
cmdclass={
'build_ext': BuildExtension
})
问题解决
简单来说就是修改所有有用到的setup.py文件中的nvcc_args
,对于GPU是RTX 2080Ti的用户那就修改成compute_70
对应的参数。
- 猜想
compute_75应该适用于Turing架构的RTX 2080Ti才对的,我猜可能是我CUDA并非2080Ti可用最高版本10.0的原因,如果我的CUDA版本是10.0,用compute_75应该是OK的。而本机器现在的CUDA是9.0,应匹配compute_70。 - 另一种解决方案就是升级CUDA了吧,将我的9.0升到10.0,但是比较麻烦,就放弃了
参考
[1] DAIN
[2] CUDA error trying to run demo following requirements
[3] Colab compatibility improvements
[4] Unclear installation description
[5] Matching CUDA arch and CUDA gencode for various NVIDIA architectures
[6] nvcc fatal : Unsupported gpu architecture ‘compute_75’
[7] nvcc fatal : Unsupported gpu architecture ‘compute_75’
码字不易,如果您觉得有帮助,欢迎点赞和收藏~~