CUDA编译.cu文件报错unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check;
最近使用cuda11.3编译.cu文件,报错:
#error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
详细信息:
(base) devil@hp:/tmp$ nvcc ./y.cu -o stream_legacy
In file included from /usr/local/cuda-11.3/bin/../targets/x86_64-linux/include/cuda_runtime.h:83,
from <command-line>:
/usr/local/cuda-11.3/bin/../targets/x86_64-linux/include/crt/host_config.h:139:2: error: #error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
139 | #error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
| ^~~~~
在网上查找相关问题,判断为gcc版本过高,与cuda的nvcc不兼容,查看本机的gcc版本:
gcc -v
安装版本10的gcc和g++:
sudo apt-get install gcc-10
sudo apt-get install g++-10
为nvcc编译器指定特定版本的gcc:
由于linux中可以有多个版本的gcc和g++,我们可以为系统默认的gcc和g++指定特定的默认版本,但是对于cuda的nvcc来说有更方便的方法,那就是nvcc会优先读取自身路径下的gcc然后如果没有再读取系统默认路径下的gcc,因此我们只需要为nvcc设置特定版本gcc的软连接即可:
sudo ln -s /usr/bin/gcc-10 /usr/local/cuda/bin/gcc
============================================================
参考:
https://blog.csdn.net/qq_28660035/article/details/78703095
https://zhuanlan.zhihu.com/p/518431589
https://blog.csdn.net/qq_45779334/article/details/123169473
posted on 2022-11-07 09:13 Angry_Panda 阅读(3109) 评论(0) 编辑 收藏 举报