1、进入pytoch官网:PyTorch
找到pytorch-gpu版本,看到CUDA11.8、11.7、CPU,这里我选择安装CUDA11.8
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-y6JVrCh3-1690786743470)(./assets/image-20230731143928662.png)]](https://img-blog.csdnimg.cn/8e7d6d0dd0ec4934a6cc8028adf448b8.png)
2、下载CUDA Toolkit:CUDA Toolkit 11.8 Downloads | NVIDIA Developer
3、下载CUDANN:cuDNN Download | NVIDIA Developer
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-oDnsjvvl-1690786743471)(./assets/image-20230731144131696.png)]](https://img-blog.csdnimg.cn/d85a5efac08f4fbb89026061193bce02.png)
命令行输入nvidia-smi,查看驱动信息
输入nvcc --version 进行检查

4、根据pytoch官方指令下载pytorch
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
5、验证:
>>> import torch
>>> torch.__version__
'2.0.0+cu118'
>>> torch.cuda.is_available()
True
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x000001F2F10AAC70>
>>> torch.cuda.device_count()
1
>>> torch.cuda.get_device_name(0)
'NVIDIA GeForce GTX 1060 with Max-Q Design'
@著作:机智的小神仙儿
@时间:2023.7.31


















