在Windows 11 WLS2 Ubuntu20.04 环境下,PaddleDetection运行报错的解决方法
- 报错如下
(paddle) lin@Home:~/Projects/paddle/PaddleDetection$ python ppdet/modeling/tests/test_architectures.py
W1202 19:55:59.357626 168677 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime API Version: 11.7
W1202 19:55:59.358676 168677 gpu_resources.cc:149] device: 0, cuDNN Version: 8.9.
W1202 19:56:01.240932 168677 dynamic_loader.cc:303] The third-party dynamic library (libcuda.so) that Paddle depends on is not configured correctly. (error code is libcuda.so: cannot open shared object file: No such file or directory)
Suggestions:
1. Check if the third-party dynamic library (e.g. CUDA, CUDNN) is installed correctly and its version is matched with paddlepaddle you installed.
2. Configure third-party dynamic library environment variables as follows:
- Linux: set LD_LIBRARY_PATH by `export LD_LIBRARY_PATH=...`
- Windows: set PATH by `set PATH=XXX;
--------------------------------------
C++ Traceback (most recent call last):
--------------------------------------
No stack trace in paddle, may be caused by external reasons.
----------------------
Error Message Summary:
----------------------
FatalError: `Segmentation fault` is detected by the operating system.
[TimeInfo: *** Aborted at 1701518161 (unix time) try "date -d @1701518161" if you are using GNU date ***]
[SignalInfo: *** SIGSEGV (@0x0) received by PID 168677 (TID 0x7f18935b3280) from PID 0 ***]
Segmentation fault
- 解决方法:
a. 通过命令sudo find / -name libcuda.so*
找到libcuda.so这个文件在哪。和正常的Ubuntu系统不同的是,WLS2中的Ubuntu的CUDA .so 文件居然是在/usr/lib/wsl/lib
下的,因此paddle找不到libcuda.so
在哪。
(paddle) lin@Home:~/Projects/paddle/PaddleDetection$ sudo find / -name libcuda.so*
/usr/lib/wsl/lib/libcuda.so
/usr/lib/wsl/lib/libcuda.so.1
/usr/lib/wsl/lib/libcuda.so.1.1
/usr/lib/wsl/drivers/nv_dispi.inf_amd64_8c8de08a85de4474/libcuda.so.1.1
/usr/lib/x86_64-linux-gnu/libcuda.so
/usr/local/cuda-12.3/targets/x86_64-linux/lib/stubs/libcuda.so
/usr/local/cuda-12.3/targets/x86_64-linux/lib/libcuda.so
b. 将usr/lib/wsl/lib
路径写到~/.bashrc
文件里
export PATH=/usr/local/cuda-12.3/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda
c. source ~/.bashrc
之后就可以正常使用paddle了
(paddle) lin@Home:~/Projects/paddle/PaddleDetection$ python ppdet/modeling/tests/test_architectures.py
W1202 20:11:51.214569 172275 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 12.2, Runtime API Version: 11.7
W1202 20:11:51.215454 172275 gpu_resources.cc:149] device: 0, cuDNN Version: 8.9.
.......
----------------------------------------------------------------------
Ran 7 tests in 3.014s
OK