Anaconda环境首先需要去官网去确认你要下载的版本,根据你的Ubuntu的环境。博主使用离线下载的方案,选择的是Anaconda3-4.0.0-Linux-x86_64.
也可以直接通过命令行下载:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.0.0-Linux-x86_64.sh安装
安装命令比较简单,安装进程直接按照指示走就可
bash Anaconda3-4.0.0-Linux-x86_64
注意这里选择yes,这样省去后面自己配置的过程。
输入conda命令,发现没有找不到该命令
网上查询之后,才发现没有激活配置文件,输入如下命令就成功了。
source ~/.bashrc
记得激活呀!!
记得激活呀!!
往往可以建立多个虚拟环境适配不同项目的环境要求。
国内镜像配置安装配置镜像的话,使用国内镜像的话会快很多。这里选用清华镜像会使安装快很多。
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.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --set show_channel_urls yes创建环境
接下来,针对自己的项目,创建虚拟镜像
conda create -n pytorch-gpu python==3.8
哎,SSL连接不上。
- 原因探索:
1.可能是由于未使用国内的镜像源,所以非常的慢
2.可能由于conda是比较低的版本,需要更新
在已经配置国内镜像的情况,因此对conda版本进行更新
conda update --all
还是不行。于是乎,开始了遍历各大博主的解决方案的无尽头的尝试中。经过无数次的尝试的,吐血发现两个改动起了作用。
- 添加这两条命令ssl_verify: true和channel_priority: flexible
- 将所有的https都改成http
修改后,condarc文件内容如下:
channels: - http://mirrors.ustc.edu.cn/anaconda/pkgs/main/ - http://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ show_channel_urls: true ssl_verify: true channel_priority: flexible
输入创建环境命令,终于成功了(泪流满面啊啊啊!!!)
conda create -n pytorch-gpu python==3.8
最后激活环境
source activate pytorch-gpu
OK,现在你已经成功进入了pytorch-gpu虚拟环境了
安装Pytorch现在开始在虚拟环境下安装pytorch,按理来说,pytorch与,torchvision都是配套的,你可以在官网上查找匹配方案``https://pytorch.org/get-started/previous-versions/`
这里我的环境是cuda10.1, pytorch 1.7
使用conda命令直接配置:
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch



