其他分享
首页 > 其他分享> > 安装PyTorch1.6

安装PyTorch1.6

作者:互联网

安装 

  1. [Optional] Check if CUDA is installed

    It 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.

  2. [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.2conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch
    CUDA 10.1conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch
    CUDA 9.2conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=9.2 -c pytorch
    CPU Only (your PyTorch code will run slower):
    conda install pytorch==1.6.0 torchvision==0.7.0 cpuonly -c pytorch

  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:
    conda install pytorch==1.6.0 torchvision==0.7.0 -c pytorch

  4. [For pip] Run pip3 install by specifying version with -f

    CUDA 10.2pip install torch==1.6.0 torchvision==0.7.0
    CUDA 10.1pip3 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.2pip3 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

下载速度慢

(点进这里,就默认了你已经安装好了anaconda,并且知道去pytorch官网找安装代码了,然后遇到了安装太慢、进度不变、多次中断的情况,这时候通常的做法,是添加清华源镜像的下载路径。但是肯定会有人和我一样,路径改了也不好使啊!!!)(补充一下镜像源方案吧!)

一、清华镜像源方案
该方案就是将官网的下载路径,改到清华镜像源的路径,先用activate激活自己之前创建的环境后,在命令行输入以下代码:

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/

然后再去pytorch官网复制下载代码,记得删掉后面的-c pytorch,因为它表示从官网进行下载,不从清华镜像源下。
 

标签:1.6,torchvision,PyTorch1.6,pytorch,conda,CUDA,install,安装
来源: https://blog.csdn.net/qq_30460949/article/details/122874196