Conda杂记

参考

更换仓库源

1
2
3
4
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
# 换回默认源
conda config --remove-key channels

清理

1
2
3
4
# 删除没有用的包
conda clean -p
# 删除所有的安装包及cache
conda clean -y -all

导出与安装依赖

1
2
conda list -e > requirements.txt
conda install --yes --file requirements.txt

虚拟环境

1
2
3
4
5
6
7
8
9
10
11
12
# 创建
conda create -n your_env_name python=3.5
# 激活
conda activate your_env_name
# 安装
conda install package-name -c optional-channel-name
# 卸载包
conda remove package-name
# 退出
conda deactivate
# 删除
conda remove -n your_env_name --all

安装pytorch=0.4.1

参考:https://www.pytorchtutorial.com/pytorch-installation-commands/

1
2
3
4
5
6
7
conda install -c pytorch cudatoolkit=8.0
pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-linux_x86_64.whl
pip install numpy
pip install torchvision

# conda install pytorch=0.4.1 torchvision -c pytorch
# conda install torchvision=0.2.1 cudatoolkit=8.0 -c pytorch

安装tensorflow=1.4.1

1
2
conda install cudatoolkit==8.0
conda install tensorflow-gpu=1.4.1