步骤
新建虚拟环境,名为tf2,python版本3.6
注:如果不加镜像链接,创建将很慢.
conda create --name tf2 python=3.6 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
进入虚拟环境tf2并使用pip安装库文件,比如安装opencv和tensorflow
conda activate
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
退出当前虚拟环境
conda deactivate
再比如安装pytorch:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
上述命令已经安装了对应的cuda版本10.1,则还需要安装cudnn,命令如下:
conda install cudnn=7.6.5
之后通过命令查看安装的库以及版本信息:
conda list
如果闲麻烦,可以直接打开终端,分别执行下面命令,然后再去安装库文件
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 --set show_channel_urls yes
关于虚拟环境的其它操作可参考:conda虚拟环境创建和管理