1、安装CUDA
下载 CUDA 12.1 cuda_12.1.0_531.14_windows.exe,然后完成安装,如下图:
2、安装cudnn
下载CUDNN 8.9.1 cudnn-windows-x86_64-8.9.1.23_cuda12-archive.zip,注意需要先登录才能下载。
因为使用paddleocr时有版本对应要求,目前CUDA12.1对应的CUDNN版本为8.9.1。
下载后,如下图所示:
将这三个文件夹复制到cuda的安装目录下即可。
3、安装PyTorch
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
4、安装飞桨
python -m pip install paddlepaddle-gpu==2.6.1.post120 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html
python -m pip install paddleocr==2.6.1.3
问题1
RuntimeError: (PreconditionNotMet) The third-party dynamic library (cudnn64_8.dll) that Paddle depends on is not configured correctly. (error code is 126)
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; (at ..\paddle\phi\backends\dynload\dynamic_loader.cc:305)
此问题可能与飞桨要求的CUDNN和CUDA版本没有对应上,但笔者没有遇到此问题。
又或者cudnn64_8.dll不在环境变量。
又或者你在Pycharm中打开时安装的cudnn和cuda,此时应该把Pycharm全部关闭,重新打开。
问题2
Could not locate zlibwapi.dll. Please make sure it is in your library path!
下载zlibwapi.dll,放到cuda的bin目录下即可。
问题3
RuntimeError: (PreconditionNotMet) The third-party dynamic library (cublas64_118.dll;cublas64_11.dll) that Paddle depends on is not configured correctly. (error code is 126)
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.
到cuda安装目录的bin目录下,找到cublas64_12.dll,将其复制一个副本为cublas64_11.dll即可。