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   Angry_Panda  阅读(4471)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示