具体问题在pykeops.common.gpu_utils
的函数get_gpu_number()
中
libnames = ("libcuda.so", "libcuda.dylib", "cuda.dll")
for libname in libnames:
try:
cuda = ctypes.CDLL(libname)
except OSError:
continue
else:
break
else:
print("[pyKeOps]: Warning, no cuda detected. Switching to cpu only.")
return 0 # raise
nGpus = ctypes.c_int()
error_str = ctypes.c_char_p()
result = cuda.cuInit(0)
ctypes.CDLL(libname)
找不到libcuda.so
,使用命令locate libcuda.so
得到结果
/usr/lib/x86_64-linux-gnu/libcuda.so.1
/usr/lib/x86_64-linux-gnu/libcuda.so.450.51.06
/usr/lib/x86_64-linux-gnu/stubs/libcuda.so
/usr/local/cuda-10.1/doc/man/man7/libcuda.so.7
/usr/local/cuda-10.1/targets/x86_64-linux/lib/stubs/libcuda.so
/usr/local/cuda-10.2/doc/man/man7/libcuda.so.7
/usr/local/cuda-10.2/targets/x86_64-linux/lib/stubs/libcuda.so
/usr/local/cuda-11.0/doc/man/man7/libcuda.so.7
/usr/local/cuda-11.0/targets/x86_64-linux/lib/stubs/libcuda.so
/usr/local/cuda-9.0/doc/man/man7/libcuda.so.7
/usr/local/cuda-9.0/lib64/stubs/libcuda.so
/usr/share/man/man7/libcuda.so.7
/usr/share/man/man7/libcuda.so.7.gz
根据nvidia-smi
显示驱动的版本是450.51.06
所以正确的cuda
应该是/usr/lib/x86_64-linux-gnu
目录下的3项,那么修改的方法有两种:
1. 在libnames里添加libcuda.so.1
# libnames = ("libcuda.so", "libcuda.dylib", "cuda.dll")
libnames = ("libcuda.so.1", "libcuda.so", "libcuda.dylib", "cuda.dll")
2. 在LD_LIBRARY_PATH里添加/usr/lib/x86_64-linux-gnu/stubs
vim ~/.profile
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/stubs${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
:wq