用pytorch for C++ 编译的问题

报错:Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason. The CUDA library MUST be loaded, EVEN IF you don’t directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,–no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don’t depend on any of their symbols. You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library. (initCUDA at /home/…/pytorch/aten/src/ATen/detail/CUDAHooksInterface.h:58)
目的:配置一个程序,程序用到了libtorch,因为笔记本没有显卡,所以就改成了CPU版本的,运行,但是编译总是出错,说是没有cuda,然而CPU的也用不到cuda啊,,,,

解决:后来发现,源程序是要求用cuda的,我事先编译了一遍,完了才改的程序,改成只用CPU的,再编译的时候,总是有之前的缓存数据要链接到cuda,我删掉build文件夹,重新来编译一遍,就没事了。everything is fine,,,,,

ps:下载老版本的libtorch:可以用wget + 官网的版本链接。
如:

wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.4.0%2Bcpu.zip
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值