1. 基本命令
1.环境
创建环境,xx代表你需要的名字
conda create -n xx python==3.6
查看虚拟环境
conda info --env
删除, xx为要删除的虚拟环境的名字
conda remove -n xx --all
2镜像
添加镜像(需要注意你添加的镜像是否还能使用,比如清华在之前有段时间是末)
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/conda-forge/
常用镜像(待补充)
http://pypi.mirrors.ustc.edu.cn/ #中国科学技术大学
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 config --show channels
如果要删除镜像
conda config --remove-key channels #删除所有的镜像源,恢复到默认
or
conda config --remove channels [urls] #删除指定的镜像源
3 tf
TensorFlow-gpu1.14+CUDA10.1+cuDNN7.5.6
用conda命令会比pip好
conda install tensorflow-gpu==1.14.0
4 torch安装
https://pytorch.org/get-started/previous-versions/ 查看torch与cuda版本对应关系:(我这里是CUDA 10.1)
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
有时候需要离线安装一些包(whl,tar(install这个的时候末尾要加bz2)后缀的压缩包)
conda install C:\Users\dell\Downloads\pytorch-1.9.1-py3.8_cuda11.1_cudnn8_0.tar.bz2
numpy 和scipy
一般来说numpy可以正常安装成功,而scipy有很大概率失败,原因是scipy要依赖于numpy和其他的很多库(如LAPACK/BLAS),但这些库在windows下并不是可以简单获取的,详情参见这里:Building From Source on Windows
不过,经过查找,发现可以通过另外一个方式解决,即上面某些答主提到的一个非官方维护的第三方库在Windows下的处理:http://www.lfd.uci.edu/~gohlke/pythonlibs/
https://download.pytorch.org/whl/torch_stable.html
https://pypi.tuna.tsinghua.edu.cn/simple/numpy/
pip install numpy-1.19.5+mkl-cp37-cp37m-win_amd64.whl
pip install scipy-1.7.3-cp37-cp37m-win_amd64.whl
numpy→scipy→matplotlib→sklearn
在线安装 第一个网站为url,第二个网址为镜像
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.doubanio.com/simple
离线安装包
PyPI搜索需要的包,一般是whl,tar.gz,zip
#先cd 到包的目录
#for whl
pip install xxx.whl
#for tar.zg
tar -zxvf xx.tar.gz
cd xx
pip install -e .