CUDAExtention安装找不到.o文件

文章讲述了在使用TorchANI时遇到的编译错误,由于cudatoolkit11.4对gcc版本有要求,必须低于11。作者提出降级gcc到10版本,或在编译参数中添加`-allow-unsupported-compiler`来解决。
部署运行你感兴趣的模型镜像

报错信息

g++ -pthread -B /opt/conda/compiler_compat -shared -Wl,-rpath,/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -L/opt/conda/lib -Wl,-rpath,/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -L/opt/conda/lib /ee/torchani/build/temp.linux-x86_64-3.10/torchani/cuaev/aev.o /ee/torchani/build/temp.linux-x86_64-3.10/torchani/cuaev/cuaev.o -L/opt/conda/lib/python3.10/site-packages/torch/lib -L/usr/local/cuda/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-3.10/torchani/cuaev.cpython-310-x86_64-linux-gnu.so
/opt/conda/compiler_compat/ld: cannot find /ee/torchani/build/temp.linux-x86_64-3.10/torchani/cuaev/aev.o: No such file or directory
/opt/conda/compiler_compat/ld: cannot find /ee/torchani/build/temp.linux-x86_64-3.10/torchani/cuaev/cuaev.o: No such file or directory
collect2: error: ld returned 1 exit status
error: command ‘/usr/bin/g++’ failed with exit code 1

核心在于.o文件没有正确生成。

问题定位

通过手动调用build.ninja文件得到详细报错。

In file included from /usr/local/cuda/include/cuda_runtime.h:83,
from :
/usr/local/cuda/include/crt/host_config.h:139:2: error: #error – unsupported GNU version! gcc versions later than 11 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 11 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.
| ^~~~~
ninja: build stopped: subcommand failed.

看到核心问题在于,cudatoolkit==11.4自带一个编译时的GNU版本检查。
gcc版本大于11就不能接受。
看了下环境里的gcc/g++都是11版本。
也就是说得回退10版本。

可以看官方的gcc版本推荐。

https://docs.nvidia.com/cuda/archive/11.4.4/cuda-installation-guide-linux/index.html

在这里插入图片描述
看来还是搞个9版本吧。
问题是9版本太过古老,一般镜像站是找不到包的。
得切回debian官方源。

或者按照提示,
extra_compile_args里面

nvcc_args = "-allow-unsupported-compiler"
return CUDAExtension(
       ...,
        extra_compile_args={'cxx': cxx_args, 'nvcc': nvcc_args})

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值