作者321yu
编辑于2022-05-16
这是我第二次安装pytorch,我去年安装过一次gpu,但是安装方法1~2就非常顺利换源就能安装好,这次无论如何都报错,折磨人啊,最后方法3手动安装才成功。
前提是我在已经存在清华源的情况下,进行对pytorch的安装,官网Previous PyTorch Versions | PyTorch安装pytorch的conda语句:
对应自己的cuda11.0版本,python3.8
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 #官方最后有-c pytorch,(去掉-c pytorch是清华镜像下载,速度快些)
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- torchaudio==0.7.2
- torchvision==0.8.2
- pytorch==1.7.1
Current channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/win-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
意思是我不能通过设置的通道下载这三个包。
参考认为写的不错的:
win10使用清华源快速安装指定版本的pytorch-GPU
Anaconda(Win10)使用清华镜像源安装PyTorch步骤及Http错误问题解决方法
以下方法都是在conda环境的命名为torch01文件中哈~
(78条消息) 解决:An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent…_旋涡小林的博客-CSDN博客
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
方法1报错:
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
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.
(78条消息) CondaHTTPError:HTTP 000 CONNECTION FAILED for url<https://mirrors.tuna.tsinghua.edu.cn/anaconda***_我超级厉害的的博客-CSDN博客
channels:
- defaults
show_channel_urls: true
channel_alias: http://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
方法2还是报错了:
PackagesNotFoundError: The following packages are not available from current channels:
意思是我们想要安装的3个包不能通过上述的通道下载。
怎么解决呢?
下载地址
注意:找的是gpu版本。
参考:(78条消息) Pytorch GPU版本whl文件安装_龙倚亭的博客-CSDN博客_pytorch whl文件
我想要下载cu110,torch1.7.1,python3.8。下载下面的版本:
#默认路径
(base) C:\Users\xxx>
#下载下来的版本复制到默认路径
torch-1.7.1+cu110-cp38-cp38-win_amd64.whl
conda activate激活环境tf01后,使用pip install torch-1.7.1+cu110-cp38-cp38-win_amd64.whl
命令进行安装:
出现Successfully installed torch-1.7.1+cu110 typing-extensions-4.2.0 。
最大的一个库已经被我们搞定了,最后按照pytorch官网Previous PyTorch Versions | PyTorch的wheel版本对应的pip指令安装剩下两个包:
# CUDA 11.0 pip指令复制
pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
(79条消息) 检查PyTorch GPU版本是否安装成功_敲代码的小风的博客-CSDN博客_判断pytorch是否安装成功
#指令
python
import torch
print(torch.__version__)
print(torch.cuda.is_available())
嘻嘻~