Windows安装CUDA、cuDNN并使用GPU跑torch和onnxruntime
选择版本
从零开始安装环境
为了让 onnxruntime 和 torch 都能跑起来,参考他们官网的版本说明
这里选择以下版本
CUDA 12.4
cuDNN 9.1.1
onnxruntime 1.19.x
安装 CUDA
下载 CUDA Toolkit 12.4,运行安装一路下一步。
安装 cuDNN
下载 cudnn_9.1.1_windows.exe,运行安装一路下一步。
安装 pytorch
根据其官网安装说明,命令为
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
安装 onnxruntime
目前 onnxruntime 较新版本都能够支持前文中选定的环境,卸载cpu版本后,直接安装即可。
pip uninstall onnxruntime
pip install onnxruntime-gpu
完成
执行完上述步骤后,重启系统,环境就装好了。