conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/win-64/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/win-64/
conda config --add channels https://anaconda.org
conda config --set show_channel_urls yes
丢个链接:https://pytorch.org/
import torch
import torchvision
print(torch.__version__)
print(torchvision.__version__)
print( torch.cuda.is_available() ) # True: 可以,False: 不可以
完成!!!!!!!!
创建Pytorch虚拟环境
conda create --name pytorch python=3.8
然后进入pytorch虚拟环境:
activate pytorch
安装pytorch
输入上述官网提供的安装命令:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
安装报错,pytorch包无法下载安装:
-
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/pytorch/win-64/pytorch-1.0.1-py3.6_cuda90_cudnn7_1.tar.bz2>
-
Elapsed: -
-
An HTTP error occurred when trying to retrieve this URL.
-
HTTP errors are often intermittent, and a simple retry will get you on your way.
然后执行pytorch的安装命令:
conda install pytorch torchvision cudatoolkit=10.1
结果终于成功!!!!!!