ubunntu Anaconda 使用说明

167 阅读1分钟

 

Ubuntu下面就不要直接在环境中安装cuda这些难以安装的内容了,直接安装anaconda然后再创建虚拟环境就好了。安装anaconda很简单,只要在属性里面将可执行勾选,然后sudo ./xxxx.sh就行了

安装结束需要更改Pip和conda源,不改的话影响下载速度

pip源改变方法:

在home下创建.pip文件夹,然后在.pip文件夹中创建pip.conf文件,然后输入下列命令,输入多个源

 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
 index-url = http://mirrors.aliyun.com/pypi/simple/
 index-url = https://pypi.mirrors.ustc.edu.cn/simple/

conda源更改方法:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/


conda config --set show_channel_urls yes

创建环境

conda create -n test1 python=3.6

删除环境

conda remove -n test1 --all

使用指定的环境

source activate test1

关闭指定的环境

source deactivate test1

进入环境后安装软件,比如pytorch1.2 torchvision 0.4.0 cuda9.2

conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 -c pytorch

conda install 包名

pip install 包名
如果源中没有这个包,可以指定地址
pip install <包名> -i https://pypi.douban.com/simple

conda install <包名> -i https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

查看已有的环境

conda info -e (查看所有的虚拟环境)

如果想要安装的包不能通过命令行安装,可以下载后再到虚拟环境下安装,一个可以选择的地址是main

各个版本的安装:

v1.4.0

OSX

# conda
conda install pytorch==1.4.0 torchvision==0.5.0 -c pytorch

Linux and Windows

# CUDA 9.2
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2 -c pytorch

# CUDA 10.1
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c pytorch

# CPU Only
conda install pytorch==1.4.0 torchvision==0.5.0 cpuonly -c pytorch

Wheel

OSX

pip install torch==1.4.0 torchvision==0.5.0

Linux and Windows

# CUDA 10.1
pip install torch==1.4.0 torchvision==0.5.0

# CUDA 9.2
pip install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html

# CPU only
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

v1.2.0

Conda

OSX

# conda
conda install pytorch==1.2.0 torchvision==0.4.0 -c pytorch

Linux and Windows

# CUDA 9.2
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=9.2 -c pytorch

# CUDA 10.0
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

# CPU Only
conda install pytorch==1.2.0 torchvision==0.4.0 cpuonly -c pytorch

Wheel

OSX

pip install torch==1.2.0 torchvision==0.4.0

Linux and Windows

# CUDA 10.0
pip install torch==1.2.0 torchvision==0.4.0

# CUDA 9.2
pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html

# CPU only
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

\