ubuntu20.04支持的的anaconda安装包
# 清华anaconda镜像站 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=Dwget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.03-1-Linux-x86_64.sh# 安装(一路enter和yes就行)bash 包名.sh
设置环境变量
# 添加环境变量vim ~/.bashrc# 输入i修改文件添加如下内容export PATH=/home/l/anaconda3/bin:$PATH# 启动环境变量source ~/.bashrc# 查看conda是否安装成功conda -V
conda切换清华源
# 往这个文件里写入下面的channelsvim ~/.condarc# 粘贴channels: - defaultsshow_channel_urls: truedefault_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud# 清除索引缓存,保证用的是镜像站提供的索引conda clean -i # 切换回默认源(其实这个命令就是删除上述通道)conda config --remove-key channels
conda创建虚拟环境
conda create --name xxx python=3.8
创建不成的话用下图中的方法
pytorch常用版本安装命令
# pip版torch1.12.1 cuda11.3pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113# conda版torch1.12.1 cuda11.3conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch# pip版torch2.0 cuda11.8pip install torch==2.0.0+cu118 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118# conda版torch2.0 cuda11.8conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.8 -c pytorch -c nvidia
安装不成的话用下图中的方法
测下gpu是否可用
pythonimport torchtorch.cuda.is_available()
虚拟环境改名(只能通过克隆一个新的环境,然后删掉老的环境来解决这个问题)
conda create --name python32(新名字) --clone python321(老名字)conda remove --name old_name --all
查询当前anaconda中有哪些虚拟环境
conda env list