编译时指定CC适配性解决CUDA:no kernel image is available for execution on the device

背景:
本人要在服务器上跑一份别人的pytorch的代码。流程大概是先:

python setup.py

编译所需的可执行文件,然后再

bash xxxx/xxxx.sh

进行训练。

这个服务器上有几张V100(较强的卡)和几张K80(较弱的卡)。因为V100一直是满的,所以我们就要在K80上跑。我成功编译,但每次运行都会报错:

RuntimeError: CUDA error: no kernel image is available for execution on the device

后来研究了一下显卡、compute capacity、CUDA driver、CUDA toolkit、pytorch等等之间的关系。这篇NVIDIA自己的说明不错:https://docs.nvidia.com/deploy/cuda-compatibility/index.html

之后忽然想到,会不会是CUDA检测到服务器上有V100,编译的时候就没有考虑对K80的适配性。于是找到了这篇帖子:

https://runebook.dev/zh-CN/docs/pytorch/cpp_extension

在它的指导下,编译时显式地指定了对compute capacity的适配性:

CUDA_ARCH_LIST=“3.7” python setup.py

这样编译之后,就能成功地运行了。

最后,引用一段话:

In the world of software management there exists a dreaded place called “dependency hell.” The bigger your system grows and the more packages you integrate into your software, the more likely you are to find yourself, one day, in this pit of despair.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值