安装pytorch-gpu版,不需要单独安装CUDA和cuDNN,torch的安装包已集成,只需要保证你的N卡的驱动版本号高于torch的最低要求。
一、查询cuda版本号
nvidia-smi
cuda为11.6
二、查询cuda11.6 对应的pytorch版本
Previous PyTorch Versions | PyTorch
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
三、查询是否安装成功
>>> import torch
>>> torch.__version__
'1.13.1+cu116'
>>> torch.cuda.is_available()
True
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x000002B0058357C0>
>>> torch.cuda.device_count()
1
>>> torch.cuda.get_device_name(0)
'NVIDIA GeForce RTX 3060 Laptop GPU'
>>>