1. 首页 >后端开发 >Python >

python安装GPU版 torch

在原来的环境上安装torch老是不成功

删除原来的python重新安装

然后在设值pip镜像源为清华镜像源

在C:\Users\Administrator\AppData\Roaming\pip目录下创建pip.ini文件

文件内容为

[global]                                                                                                                    
timeout = 60000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

保存过后在命令行执行

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu111

等待一段时间后安装完成

经过验证 上述安装后还是cpu版本

验证

import torch
print(torch.__version__)
pip install torch==1.10.0+cu111 torchvision==0.11.1+cu111 torchaudio==0.10.0+cu111 -f https://download.pytorch.org/whl/torch_stable.html

只能采用这个安装

但是安装过程下载很慢 

只能在官网手动下载在进行安装

官网地址 

http://download.pytorch.org/whl/torch_stable.html

我是在服务器上通过以上连接找到对应的版本

下载后,在从服务器上下载到本地

pip install numpy==1.23.5