Could not load dynamic library 'libcusolver.so.11'; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory;
题目描述:libcusolver.so.11 error
Traceback (most recent call last):
File “/home/kz/zzk/FaceDancer/multi_face_single_source.py”, line 180, in
swap(opt)
File “/home/kz/zzk/FaceDancer/multi_face_single_source.py”, line 27, in swap
tf.config.set_visible_devices(gpus[opt.device_id], ‘GPU’)
IndexError: list index out of range
然后发现:
W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘libcusolver.so.11’; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/kz/anaconda3/envs/fdancer/lib/python3.9/site-packages/cv2/…/…/lib64:
2022-12-09 10:19:29.845288: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1934] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices…
解决思路一:修改环境,是环境问题!
该问题有两个重点,第一个是CUDA组件版本,第二个是libcusolver.so.10错误。
1、CUDA 组件版本
这是 CUDA 版本与其组件版本之间的某种异步关系。
如果您使用 TensorFlow 2.4,您可能会使用 CUDA 11.0。查看 CUDA 11.0 发布文档。您可以找到以下列表。
This release of the toolkit includes the following updates:
CUDA Math libraries toolchain uses C++11 features, and a C++11-compatible standard library is required on the host.
cuBLAS 11.0.0
cuFFT 10.1.3
cuRAND 10.2.0
cuSPARSE 11.0.0
cuSOLVER 10.4.0
NPP 11.0.0
nvJPEG 11.0.0
上面的列表得出结论,CUDA 11.0 确实包含一些版本为 10 的组件。
顺便说一句,从 CUDA 11.1 开始,您会发现 cusolver.so 版本高于 11。
2、libcusolver.so.10 error
这是由环境变量 LD_LIBRARY_PATH 引起的错误。
如果您使用终端,您可能已经设置了 LD_LIBRARY_PATH,其中包含 /usr/local/cuda-11.0/lib64。
如果您使用 PyCharm 或其他 IDE,您还需要检查环境变量。
环境变量只是默认变量:PYTHONUNBUFFERED=1,你会得到:
W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library ‘libcusolver.so.10’; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory
环境变量为 LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:/usr/local/lib 时,您将得到:
I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
最终解决的代码命令!
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:/usr/local/lib:$LD_LIBRARY_PATH
感谢老师早上帮我debug,呜呜~!
2022-12-09 10:19:29
参考链接
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠