众所周知,由于一些特殊的原因,PyTorch 的官网要么访问不了,要么安装那部分点击没有反应。因此我们在这里为大家整理一份安装命令,方便大家查阅。
文章目录
Linux
使用 conda
以下命令适用于 Python 2.7 – 3.7。
CPU 版本:
1 | conda install pytorch-cpu torchvision-cpu -c pytorch |
CUDA 8:
1 | conda install pytorch torchvision cuda80 -c pytorch |
CUDA 9.0:
1 | conda install pytorch torchvision -c pytorch |
CUDA 9.2:
1 | conda install pytorch torchvision cuda92 -c pytorch |
使用 pip
Python 2.7
CPU 版本:
1 2 3 4 5 | pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl pip install torchvision # if the above command does not work, then you have python 2.7 UCS2, use this command pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27m-linux_x86_64.whl |
CUDA 8:
1 2 3 4 5 | pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl pip install torchvision # if the above command does not work, then you have python 2.7 UCS2, use this command pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp27-cp27m-linux_x86_64.whl |
CUDA 9.0:
1 | pip install torch torchvision |
CUDA 9.2:
1 2 3 4 5 | pip install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl pip install torchvision # if the above command does not work, then you have python 2.7 UCS2, use this command pip install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp27-cp27m-linux_x86_64.whl |
Python 3.5
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-linux_x86_64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-linux_x86_64.whl pip3 install torchvision |
CUDA 9.0:
1 | pip3 install torch torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp35-cp35m-linux_x86_64.whl pip3 install torchvision |
Python 3.6
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-linux_x86_64.whl pip3 install torchvision |
CUDA 9.0:
1 | pip3 install torch torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-linux_x86_64.whl pip3 install torchvision |
Python 3.7
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl pip3 install torchvision |
CUDA 9.0:
1 | pip3 install torch torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl pip3 install torchvision |
MacOS
使用 conda
以下命令适用于 Python 2.7 – 3.7。
CPU 版本:
1 | conda install pytorch torchvision -c pytorch |
CUDA 8,CUDA 9.0,或 CUDA 9.2:MacOS 不支持 CUDA,如果需要,则需要从源码编译安装。
使用 pip
Python 2.7
CPU 版本:
1 | pip install torch torchvision |
CUDA 8,CUDA 9.0,或 CUDA 9.2:MacOS 不支持 CUDA,如果需要,则需要从源码编译安装。
Python 3.5,3.6,3.7
CPU 版本:
1 | pip3 install torch torchvision |
CUDA 8,CUDA 9.0,或 CUDA 9.2:MacOS 不支持 CUDA,如果需要,则需要从源码编译安装。
Windows
使用 conda
Python 2.7
PyTorch 不支持在 Windows 上的 Python 2.7 版本,请使用 Python 3 版本。
Python 3.5,3.6,3.7
CPU 版本:
1 2 | conda install pytorch-cpu -c pytorch pip3 install torchvision |
CUDA 8:
1 2 | conda install pytorch cuda80 -c pytorch pip3 install torchvision |
CUDA 9.0:
1 2 | conda install pytorch -c pytorch pip3 install torchvision |
CUDA 9.2:
1 2 | conda install pytorch cuda92 -c pytorch pip3 install torchvision |
使用 pip
Python 2.7
PyTorch 不支持在 Windows 上的 Python 2.7 版本,请使用 Python 3 版本。
Python 3.5
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-win_amd64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-win_amd64.whl pip3 install torchvision |
CUDA 9.0:
1 2 | pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp35-cp35m-win_amd64.whl pip3 install torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp35-cp35m-win_amd64.whl pip3 install torchvision |
Python 3.6
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-win_amd64.whl pip3 install torchvision |
CUDA 9.0:
1 2 | pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp36-cp36m-win_amd64.whl pip3 install torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-win_amd64.whl pip3 install torchvision |
Python 3.7
CPU 版本:
1 2 | pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp37-cp37m-win_amd64.whl pip3 install torchvision |
CUDA 8:
1 2 | pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp37-cp37m-win_amd64.whl pip3 install torchvision |
CUDA 9.0:
1 2 | pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp37-cp37m-win_amd64.whl pip3 install torchvision |
CUDA 9.2:
1 2 | pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp37-cp37m-win_amd64.whl pip3 install torchvision |
以上命令均为安装 PyTorch 的最新版本,要安装特定的老版本,请参考这个页面。
还等什么,快点加入收藏吧!
本站微信群、QQ群(三群号 726282629):