在C ++中加载torchscript模型:没有ATen_cuda库,无法初始化CUDA

时间:2019-10-07 15:43:51

标签: c++ windows pytorch

我用带有GPU支持的Pytorch构建了CNN。它在python中工作正常,我想使用VS2017将其导入我的C ++应用程序中。我正在按照herehere这些说明进行操作。
我可以构建和运行该应用程序,但是在加载模型时出现此错误:

error loading the model
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 
C:\w\1\s\windows\pytorch\aten\src\ATen/detail/CUDAHooksInterface.h:63)
(no backtrace available)

我无法在ATen_cuda file中找到任何C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
有人可以使用Windows C ++ VS2017 Pytorch且具有GPU工作示例吗?

1 个答案:

答案 0 :(得分:0)

我使用每晚的build解决了问题,该文件附带所有必需的pytorch个dll,随cuda一起提供。
看来Windows的conda安装程序没有安装最新的pytorch stable 1.2,但安装较旧的1.0.1。 Windows conda python 3.7的每晚构建会安装更新的1.3