conda命令⾏使⽤及在pycharm调⽤conda环境
conda命令⾏搭建环境
在Ubuntu系统使⽤:
1.安装:sudo sh Anaconda3xxxxx-Linux-x86_64.sh
爱的飞行日记 歌词
Do you accept the license terms? [yes|no]
yes
Anaconda3 will now be installed into this location:
/xxx/anaconda3
-Press ENTER to confirm the location
-Press CTRL-C to abort the installation
-Or specify a different location below
/
usr/local/anaconda3 (⾃定义anaconda地址)
Do you wish the installer to initialize Anaconda3
in your xxx/.bashrc ? [yes|no]
yes
天之涯2.初始化:重启终端后如果conda命令⽆法使⽤,则⼿动更新bashrc:
sudo gedit ~/.bashrc
在⽂件末尾添加export PATH="/usr/local/anaconda3/bin:$PATH"(⾃⼰的anaconda地址)后保存
再运⾏source ~/.bashrc
重启终端
如果终端语句前没有(base),运⾏conda init即可———————————————————————————————————————————————————————————————在base下新建⼀个环境xxx,可在envs⽂件夹中到
conda create -n xxx python=3.9
在base下激活环境
conda activate xxx
在xxx中退出环境⾄base
conda deactivate
查看当前环境中安装了哪些包
conda list
通过conda安装
根据需要选择安装的版本
显卡查看lspci | grep -i vga
使⽤nvidia GPU可以:lspci | grep -i nvidia
Nvidia⾃带⼀个命令⾏⼯具可以查看显存的使⽤情况以及驱动和cuda版本:nvidia-smi
conda install pytorch torchvision torchaudio -c pytorch
其中-c 是选择从哪个channe下载,-从pytorch是从pytorch的官⽹下载
安装前可先添加channel,如清华的镜像源,然后去掉-c pytorch,就会从已添加的channel中下载
清华源⽤这个
conda config --add channels mirrors.tuna.tsinghua.edu/anaconda/pkgs/free/
conda config --add channels mirrors.tuna.tsinghua.edu/anaconda/pkgs/main/
conda config --add channels mirrors.tuna.tsinghua.edu/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
中科⼤源:
conda config --add channels mirrors.ustc.edu/anaconda/pkgs/main/
属于歌词conda config --add channels mirrors.ustc.edu/anaconda/pkgs/free/
conda config --add channels mirrors.ustc.edu/anaconda/cloud/conda-forge/
conda config --add channels mirrors.ustc.edu/anaconda/cloud/msys2/
conda config --add channels mirrors.ustc.edu/anaconda/cloud/bioconda/
conda config --add channels mirrors.ustc.edu/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
然后:
conda install pytorch torchvision torchaudio
即可
delete channel:
conda config --remove-key channels
注意:经测试如果安装后⽆法使⽤cuda,可能是channel下载的pytorch是cpu版本的问题,可以删除所有的channel重新安装pytorch
复制某⼀个环境
conda create --name yyy --clone xxx
删除某个环境
conda remove -n xxx --all
显⽰有哪些环境
conda info -e酷狗音乐2010
终⽌当前步骤
ctrl+c
姜珮瑶
在pycharm中调⽤conda的环境
在选择解释器界⾯选择conda environment
选择exist environment,将⽬标环境⽂件夹下(anacona/envs/xxx/)的添加进去
魏晨初恋
调⽤完conda环境后,此时pycharm下⽅的terminal就等同于conda进⼊该环境后的conda命令⾏界⾯可以使⽤conda命令,效果是⼀样的