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 阅读(4471) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)