问题背景:
在运行fpn.pytorch项目时,遇到了undefined symbol: __cudaPopCallConfiguration错误。
原因分析:
笔者遇到该问题的原因是,fpn.pytorch需要用nvcc-9.0对模型进行编译,但笔者的系统默认nvcc版本为10.2(系统默认在PATH路径下搜索nvcc)。
(能发现是由cuda版本不匹配而导致的错误,多亏了jshi31大佬的解答:
I find the root of the problem is the mismatch of the nvcc version and the torchcuda version. You must make sure they are the same.
Check nvcc version:nvcc --version
Check torch cuda version, go to the python interface and typeimport torch
torch.version.cuda
make sure they are the same and I solved my problem.)
解决方案:
在自己的系统上安装cuda9.0,并将系统默认cuda版本切换为cuda9.0。(相关教程:多版本cuda安装和切换)
引申阅读:
1. torch如何得知系统默认cuda版本:
(1)在torch.utils.ffi.__init__.py 中
cuda_include_dirs = glob.glob('/usr/local/cuda/include')#这句话指定了与cuda相关的include路径
(2)运行时动态库的搜索路径的先后顺序是(引自生信技能树):
1.编译目标代码时指定的动态库搜索路径;
2.环境变量LD_LIBRARY_PATH
指定的动态库搜索路径;
3.配置文件/etc/ld.so.conf中指定的动态库搜索路径;
4.默认的动态库搜索路径/lib和/usr/lib;