Windows11 安装 CUDA/cuDNN+Pytorch

一、准备工作:

查看torch版本:进入python交互环境:

>>>import torch
>>>torch.__version__

查看cuda版本:CMD窗口

nvcc --version

 如果版本不一致,需要卸载再重装。

二、安装

Windows 安装 CUDA/cuDNN - 知乎medium - Install CUDA On Windows: The Definitive Guidemedium - Installing CUDA and cuDNN on windows 10windows下安装配置cudn和cudnn版本对应关系需要注意的是一定要选择 TensorFlow 和 CUDA相匹配,还需要…https://zhuanlan.zhihu.com/p/99880204查看CUDA与Pytorch对应关系:

Previous PyTorch Versions | PyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.https://pytorch.org/get-started/previous-versions/本机是CUDA11.8,所以安装命令是第三个:

# ROCM 5.4.2 (Linux only)
pip install torch==2.0.0+rocm5.4.2 torchvision==0.15.1+rocm5.4.2 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/rocm5.4.2
# CUDA 11.7
pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
# CUDA 11.8
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118
# CPU only
pip install torch==2.0.0+cpu torchvision==0.15.1+cpu torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cpu

三、验证

查看pytorch对应的cuda版本

python
>>>import torch
>>>torch.version.cuda

验证GPU是否可用

import torch
import torchvision
print(torch.cuda.is_available())

猜你喜欢

转载自blog.csdn.net/chaishen10000/article/details/131211412