安装torch一次成功,不使用conda和镜像源

全网最好用windows/ubuntu安装PyTorch方法,不使用conda和镜像源

之前安装pytorch要么版本不对,要么下载老是失效,提示warning retry,现发现一种一次就能成功的方法。

离线下载

第一个网站,pytorch官网,首先要知道自己的python版本和cuda版本,一般基于自己的版本装的torch都是通用的,并不需要完全按照readme里作者指定的版本,比如cuda10.1,python3.7,在这里找到合适的下载链接,以torch1.7.0为示例,链接就是:

# CUDA 10.1
pip install torch==1.7.0+cu101 torchvision==0.8.0+cu101 torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

记住这里的三个软件版本,然后进入指令中的网站https://download.pytorch.org/whl/torch_stable.html,自己进行下载,ubuntu先右键复制链接,然后用wget 链接下载,这样就不用担心pip install和conda install断网了,且保存的离线包可以多次使用
比如cuda10.1适合安装,就去ctrl +f搜索 torch-1.7.0或cu101,一般翻页也能找到


cu101/torch-1.7.0%2Bcu101-cp37-cp37m-win_amd64.whl
cu101/torch-1.7.0%2Bcu101-cp38-cp38-linux_x86_64.whl
cu101/torch-1.7.0%2Bcu101-cp38-cp38-win_amd64.whl
cu101/torch-1.7.1%2Bcu101-cp36-cp36m-linux_x86_64.whl
cu101/torch-1.7.1%2Bcu101-cp36-cp36m-win_amd64.whl
cu101/torch-1.7.1%2Bcu101-cp37-cp37m-linux_x86_64.whl
cu101/torch-1.7.1%2Bcu101-cp37-cp37m-win_amd64.whl
cu101/torch-1.7.1%2Bcu101-cp38-cp38-linux_x86_64.whl
cu101/torch-1.7.1%2Bcu101-cp38-cp38-win_amd64.whl
cu101/torch-1.7.1%2Bcu101-cp39-cp39-linux_x86_64.whl
cu101/torch-1.7.1%2Bcu101-cp39-cp39-win_amd64.whl

其他两个软件torchvision torchaudio也要依次下载,这里的torchaudio不需要选cuda10.1

终端pip安装

最后,在本地下载好的文件位置打开终端

pip install "torch-1.7.0+cu101-cp37-cp37m-win_amd64.whl" "torchvision-0.8.0-cp37-cp37m-win_amd64.whl" torchaudio-0.7.0-cp37-none-win_amd64.whl

三个软件一起安装,可以避免版本冲突

验证是否成功

D:\Users\Downloads>python
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
>>> yes
  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值