安装PyTorch1.6

安装

  1. [Optional] Check if CUDA is installedIt is highly recommended that you have CUDA installed. Note that PyTorch 1.6.0 does not support CUDA 11.0. If you haven’t installed CUDA, please install CUDA 10.2 or install CUDA 10.1.

Once/If you have it installed, you can check its version here.

  1. [For conda on Ubuntu/Linux and Windows 10]
    Run conda install and specify PyTorch version 1.6.0
    Starting from here, we will install PyTorch 1.6.0.

CUDA 10.2: conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch
CUDA 10.1: <code>conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch</code>
CUDA 9.2: conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=9.2 -c pytorch
CPU Only (your PyTorch code will run slower):
<code>conda install pytorch==1.6.0 torchvision==0.7.0 cpuonly -c pytorch</code>
3. [For conda on macOS]
Run conda install and specify PyTorch version 1.6.0
There is only one command to install PyTorch 1.6.0 on macOS:
<code>conda install pytorch==1.6.0 torchvision==0.7.0 -c pytorch</code>
4. [For pip] Run pip3 install by specifying version with -f CUDA 10.2: pip install torch==1.6.0 torchvision==0.7.0
CUDA 10.1: pip3 install torch==1.6.0 torchvision==0.7.0 -f https://download.pytorch.org/whl/cu101/torch_stable.html
CUDA 10.0 is not officially supported by PyTorch 1.6.0, you have to install CUDA 10.2, CUDA 10.1, or CUDA 9.2.

CUDA 9.2: pip3 install torch==1.6.0 torchvision==0.7.0 -f https://download.pytorch.org/whl/cu92/torch_stable.html
PyTorch 1.6.0 also doesn’t support CUDA 9.1 or 9.0.

CPU only (GPU is much better…): pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
5. [For pip on macOS] Run pip3 install by specifying version with -f pip install torch==1.6.0 torchvision==0.7.0

&#x4E0B;&#x8F7D;&#x901F;&#x5EA6;&#x6162;

&#xFF08;&#x70B9;&#x8FDB;&#x8FD9;&#x91CC;&#xFF0C;&#x5C31;&#x9ED8;&#x8BA4;&#x4E86;&#x4F60;&#x5DF2;&#x7ECF;&#x5B89;&#x88C5;&#x597D;&#x4E86;anaconda,&#x5E76;&#x4E14;&#x77E5;&#x9053;&#x53BB;pytorch&#x5B98;&#x7F51;&#x627E;&#x5B89;&#x88C5;&#x4EE3;&#x7801;&#x4E86;&#xFF0C;&#x7136;&#x540E;&#x9047;&#x5230;&#x4E86;&#x5B89;&#x88C5;&#x592A;&#x6162;&#x3001;&#x8FDB;&#x5EA6;&#x4E0D;&#x53D8;&#x3001;&#x591A;&#x6B21;&#x4E2D;&#x65AD;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x901A;&#x5E38;&#x7684;&#x505A;&#x6CD5;&#xFF0C;&#x662F;&#x6DFB;&#x52A0;&#x6E05;&#x534E;&#x6E90;&#x955C;&#x50CF;&#x7684;&#x4E0B;&#x8F7D;&#x8DEF;&#x5F84;&#x3002;&#x4F46;&#x662F;&#x80AF;&#x5B9A;&#x4F1A;&#x6709;&#x4EBA;&#x548C;&#x6211;&#x4E00;&#x6837;&#xFF0C;&#x8DEF;&#x5F84;&#x6539;&#x4E86;&#x4E5F;&#x4E0D;&#x597D;&#x4F7F;&#x554A;&#xFF01;&#xFF01;&#xFF01;&#xFF09;&#xFF08;&#x8865;&#x5145;&#x4E00;&#x4E0B;&#x955C;&#x50CF;&#x6E90;&#x65B9;&#x6848;&#x5427;&#xFF01;&#xFF09;

&#x4E00;&#x3001;&#x6E05;&#x534E;&#x955C;&#x50CF;&#x6E90;&#x65B9;&#x6848;<br> &#x8BE5;&#x65B9;&#x6848;&#x5C31;&#x662F;&#x5C06;&#x5B98;&#x7F51;&#x7684;&#x4E0B;&#x8F7D;&#x8DEF;&#x5F84;&#xFF0C;&#x6539;&#x5230;&#x6E05;&#x534E;&#x955C;&#x50CF;&#x6E90;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x5148;&#x7528;activate&#x6FC0;&#x6D3B;&#x81EA;&#x5DF1;&#x4E4B;&#x524D;&#x521B;&#x5EFA;&#x7684;&#x73AF;&#x5883;&#x540E;&#xFF0C;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x8F93;&#x5165;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --set show_channel_urls yes

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

&#x7136;&#x540E;&#x518D;&#x53BB;pytorch&#x5B98;&#x7F51;&#x590D;&#x5236;&#x4E0B;&#x8F7D;&#x4EE3;&#x7801;&#xFF0C;<span><strong>&#x8BB0;&#x5F97;&#x5220;&#x6389;&#x540E;&#x9762;&#x7684;-c pytorch</strong></span>,&#x56E0;&#x4E3A;&#x5B83;&#x8868;&#x793A;&#x4ECE;&#x5B98;&#x7F51;&#x8FDB;&#x884C;&#x4E0B;&#x8F7D;&#xFF0C;&#x4E0D;&#x4ECE;&#x6E05;&#x534E;&#x955C;&#x50CF;&#x6E90;&#x4E0B;&#x3002;
https://varhowto.com/install-pytorch-1-6-0/

安装PyTorch1.6

如以官网首页的LTS版本PyTorch,cuda10.2,使用conda作为下载源为例,官网提供的命令行如下:

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch-lts

如果terminal已经在虚拟环境中,可以直接执行该命令行。反之需要在install后加上-n 虚拟环境名。

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/

conda config --add channels https://mirrors.aliyun.com/anaconda/cloud/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/

如果下载较慢,建议使用代理等方式。
如果您的PyTorch cuda版本与本机版本对应,可以考虑使用清华源镜像等方式。使用镜像的方式,我后期可能也会撰写相应的博文。如果不对应,说明您需要从pytorch官方源(-c指定)下载cudatoolkit包,镜像里可能没有(我用过清华源,就没有)。

版本下载​​​​​​​

下载

安装PyTorch1.6

得到所需下载的 pytorch 版本: pytorch-1.1.0-py3.6_cuda10.0.130_cudnn7.5.1_0.tar.bz2

安装PyTorch1.6

然后手动离线,按顺序安装下载包。

以管理身份打开cmd,输入cmd C:\ProgramData\Anaconda3\pkgs,进入安装包目录。然后按照顺序安装下载包

离线conda安装此包:

conda install –use-local pytorch-1.8.2-py3.6_cuda10.2_cudnn7_0.tar.bz2

conda install –use-local cudatoolkit-10.2.89-hb195166_8.tar.bz2

此步会自动将包拷入到pkgs目录下并解压

import torch
torch.cuda. is_available ()

Original: https://blog.csdn.net/qq_30460949/article/details/122874196
Author: 小魔王降临
Title: 安装PyTorch1.6

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/710085/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球