使用conda/pip安装pytorch 0.3.1教程(mac/windos/linux)

转于:https://ptorch.com/news/145.html

pytorch v0.3.1发布,添加余弦退火方案来调整学习率以及添加random_split/reduce等函数,其实更新有一段时间了,很多小伙伴安装的时候发现被墙了无法使用,所以我整理了一下方便大家使用。你可以参考自己的服务器和python版本进行选择:

一、使用conda安装pytorch 0.3.1和torchvision

包管理器 服务器 CUDA Python版本 操作方法
conda linux cuda8 python2.7 conda install pytorch torchvision -c pytorch
conda linux cuda9.0 python2.7 conda install pytorch torchvision cuda90 -c pytorch
conda linux cuda9.1 python2.7 conda install pytorch torchvision cuda91 -c pytorch
conda linux cudanone python2.7 conda install pytorch-cpu torchvision -c pytorch
conda linux cuda8 python3.5 conda install pytorch torchvision -c pytorch
conda linux cuda9.0 python3.5 conda install pytorch torchvision cuda90 -c pytorch
conda linux cuda9.1 python3.5 conda install pytorch torchvision cuda91 -c pytorch
conda linux cudanone python3.5 conda install pytorch-cpu torchvision -c pytorch
conda linux cuda8 python3.6 conda install pytorch torchvision -c pytorch
conda linux cuda9.0 python3.6 conda install pytorch torchvision cuda90 -c pytorch
conda linux cuda9.1 python3.6 conda install pytorch torchvision cuda91 -c pytorch
conda linux cudanone python3.6 conda install pytorch-cpu torchvision -c pytorch
conda osx cuda8 python2.7 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.0 python2.7 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.1 python2.7 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cudanone python2.7 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda8 python3.5 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.0 python3.5 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.1 python3.5 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cudanone python3.5 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda8 python3.6 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.0 python3.6 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cuda9.1 python3.6 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed
conda osx cudanone python3.6 conda install pytorch torchvision -c pytorch
# macOS Binaries dont support CUDA
install from source if CUDA is needed

二、使用PIP与pip3安装pytorch 0.3.1和torchvision

除了使用conda以外,我们还可以使用pip管理工具,当我们pythonpython3.x时候,可以使用pip3安装:

包管理器 服务器 CUDA Python版本 操作方法
pip osx cuda8 python2.7 pip install http://download.pytorch.org/whl/torch-0.3.1-cp27-none-macosx_10_6_x86_64.whl
pip install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.0 python2.7 pip install http://download.pytorch.org/whl/torch-0.3.1-cp27-none-macosx_10_6_x86_64.whl
pip install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.1 python2.7 pip install http://download.pytorch.org/whl/torch-0.3.1-cp27-none-macosx_10_6_x86_64.whl
pip install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cudanone python2.7 pip install http://download.pytorch.org/whl/torch-0.3.1-cp27-none-macosx_10_6_x86_64.whl
pip install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda8 python3.5 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp35-cp35m-macosx_10_6_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.0 python3.5 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp35-cp35m-macosx_10_6_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.1 python3.5 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp35-cp35m-macosx_10_6_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cudanone python3.5 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp35-cp35m-macosx_10_6_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda8 python3.6 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.0 python3.6 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cuda9.1 python3.6 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip osx cudanone python3.6 pip3 install http://download.pytorch.org/whl/torch-0.3.1-cp36-cp36m-macosx_10_7_x86_64.whl
pip3 install torchvision
# macOS Binaries dont support CUDA
install from source if CUDA is needed
pip linux cudanone python2.7 pip install http://download.pytorch.org/whl/cpu/torch-0.3.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.3.1-cp27-cp27m-linux_x86_64.whl
pip linux cuda8 python2.7 pip install http://download.pytorch.org/whl/cu80/torch-0.3.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.3.1-cp27-cp27m-linux_x86_64.whl
pip linux cuda9.0 python2.7 pip install http://download.pytorch.org/whl/cu90/torch-0.3.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/cu90/torch-0.3.1-cp27-cp27m-linux_x86_64.whl
pip linux cuda9.1 python2.7 pip install http://download.pytorch.org/whl/cu91/torch-0.3.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/cu91/torch-0.3.1-cp27-cp27m-linux_x86_64.whl
pip linux cudanone python3.5 pip3 install http://download.pytorch.org/whl/cpu/torch-0.3.1-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda8 python3.5 pip3 install http://download.pytorch.org/whl/cu80/torch-0.3.1-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda9.0 python3.5 pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.1-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda9.1 python3.5 pip3 install http://download.pytorch.org/whl/cu91/torch-0.3.1-cp35-cp35m-linux_x86_64.whl
pip3 install torchvision
pip linux cudanone python3.6 pip3 install http://download.pytorch.org/whl/cpu/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda8 python3.6 pip3 install http://download.pytorch.org/whl/cu80/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda9.0 python3.6 pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
pip linux cuda9.1 python3.6 pip3 install http://download.pytorch.org/whl/cu91/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision

3. 安装pytorch

用pip install .whl文件即可

pip install torch-0.3.0.post4-cp27-cp27mu-linux_x86_64.whl
pip install torch vision

 

有了镜像加持和.whl文件的本地化,安装很顺利 
torch vision安装非常迅速

测试

在终端中按以下顺序运行命令:

python

在打开的python命令行中运行

import torch

不报错的话即代表安装成功.

其实安装方法都大同小异,如果你想要查看pytorch 0.3.1的更新内容的话可以查看pytorch v0.3.1发布,添加余弦退火方案来调整学习率以及添加random_split/reduce等函数如果你已经安装了pytorch的话可以测试Pytorch如何更新版本与卸载,使用pip,conda更新卸载Pytorch

猜你喜欢

转载自blog.csdn.net/m0_37644085/article/details/81908260