一、我的环境
- 我的显卡是RTX4050,首先去官网下载CUDA Toolkit
https://developer.nvidia.com/cuda-downloads
我是12.3version,下载并安装
二、下载pytorch
-
大部分的参考博主都推荐的是官网下载
但是我从官网下载的,不知道为什么总是下的cpu版本
image.png
虽然是按照教程来的,选的是gpu12.1,但是结果还是False
- 我的另一个方法(参考某个博主https://cloud.tencent.com/developer/article/2022050):
- 从这里下载:https://download.pytorch.org/whl/torch_stable.html
- 选取和你匹配的version
- 我的python:3.11,CUDA Version: 12.3
- 需要下载:cu121/torch-2.1.1%2Bcu121-cp311-cp311-win_amd64.whl和cu121/torchvision-0.16.1%2Bcu121-cp311-cp311-win_amd64.whl
- 然后就通过conda prompt进入文件放置的位置
- pip install xxx.whl
- 记住先安装pytorch再安装torchversion
三、查看torch是否安装成功gpu版本
import torch
print(torch.cuda.is_available())
如果是True就是成功了
四、查看自己的nVidia状态
- cmd 输入:nvidia-smi