Linux环境下安装pytorch
由于之前安装的pytorch版本与CUDA版本不兼容,导致pytorch无法使用CUDA训练代码,将pytorch进行了卸载重装,记录一下自己卸载重装pytorch的过程,少走些弯路。
uninstall pytorch
首先是卸载原来的pytorch,显示Successfully uninstalled torch就是卸载成功了。
pip uninstall torch
Proceed (y/n)? y
Successfully uninstalled torch-1.3.0
install pytorch1.0.1 with python3.7,cuda9.0
下一步安装对应CUDA版本的pytorch版本,首先添加镜像源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --set show_channel_urls yes
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
安装pytorch,后面不要添加-c pytorch,否则会从默认的地址下载pytorch,速度会很慢。
环境:python3.7,cuda9.0,cudnn7
conda install pytorch==1.0.1 torchvision==0.2.2 cudatoolkit=9.0
The following packages will be downloaded:
package | build
---------------------------|-----------------
pytorch-1.0.1 |py3.7_cuda9.0.176_cudnn7.4.2_2 320.4 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
torchvision-0.2.2 | py_3 44 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
------------------------------------------------------------
Total: 320.5 M
Proceed ([y]/n)? y
Downloading and Extracting Packages
torchvision-0.2.2 | 44 KB | ##################################### | 100%
pytorch-1.0.1 | 320.4 MB | ##################################### | 100%
Preparing transaction: done
运行下面的代码,没有报错就是安装成功了。
import torch
import torchvision
from torchvision import transforms as trans
pytorch0.4.1 with python2.7,cuda9.0
如果还想在安装pytorch0.4.1,可以在python2.7环境下安装。
首先创建一个pytorch0.4.1的虚拟环境
create virtual environment of pytorch0.4.1 with python2.7
查看有哪些虚拟环境
conda info -e
激活虚拟环境
source activate pytorch041
安装对应版本的pytorch
conda install pytorch=0.4.1 cuda90
安装torchvision
pip install torchvision==0.2.2
最近在忙什么呢?我也不知道。总是感觉每天有很多事情,但是好像自己也没有多努力的样子,这可能就是我到现在还没有拿到offer的原因吧,继续加油吧,会有的,都会有的!!!

2768



被折叠的 条评论
为什么被折叠?



