报错: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