1,安装anaconda
下载地址:
https://www.anaconda.com/distribution/
下载后放到服务器上,
运行.sh 文本:
bash 你的文件名.sh
操作:
一直yes
检查conda安装情况
conda --version
遇到问题
编辑文件
vim .bashrc
按键盘上i键,在末尾输入
export PATH=/home/你的服务器id/anaconda3/bin:$PATH
按键盘上esc键,输入
:wq!
2,创建虚拟环境
conda create -n xx_pytorch python=3.7 #创建名为xx_pytorch的虚拟环境
source activate xx_pytorch #激活名为xx_pytorch的虚拟环境
3,在虚拟环境中安装pytorch -GPU版
pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ torch torchvision
如果报错,可能原因为版本不匹配建议直接在网页中打开https://pypi.mirrors.ustc.edu.cn/simple/
选取合适的版本下载
本人选择版本:
Python 3.7.4
torch 1.2.0
torchvision 0.4.0 对应文件torchvision-0.4.0-cp37-cp37m-manylinux1_x86_64.whl
检查包版本
pip list | grep torch
完成下载
测试
python
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
>>>
退出虚拟环境
conda deactivate
查看目前已有的虚拟环境
conda env list
遇到问题,有一些教程会推荐官网下载pytorch,对于在国内的服务器不推荐这样。
选取清华的镜像源,官网易被墙。
配环境要命呀。。。
孰能生巧,加油