- 切换至清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
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 --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --append channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- conda create --name xxxx python==xxxx
创建环境名以及python版本 - conda activate xxxxxxx
转移到要配置的环境名 - conda install xxxxxxx
下载所需的库或包 - 最后检验是否安装成功
- python
- import tensorflow as tf
- print(tf.test.is_gpu_available())
- quit()
退出环境
补充1:如何在pycharm中使用刚才配置的环境:
-
ctrl+art+s
-
点击 python interperation中的设置中的add
-
点击conda environment 中的exsiting environment
-
最后添加你想要的环境即可
补充2:使用cmd指令:
首先跳转到目标环境的地址,之后直接pip安装即可
更快速的方法:点到目标路径,再点击上面的路径输入cmd
补充3:使用pycharm配环境:
有的时候一段新代码会遇到新的库没有装,此时可以直接点击下端terminal界面,然后输入pip install xxxx
**具体实例:
安装tensorflow1:
python版本:3.6.6
tensorflow版本:tensorflow-gpu == 1.13.1
安装tensorflow2:
python版本:3.7.8
tensorflow版本:tensorflow-gpu==2.1