Ubuntu TensorFlow1与TensorFlow2共存配置
1.查看Anaconda中的所有虚拟环境
使用命令
conda info --envs
返回结果
# conda environments:
#
base /home/yc/anaconda3
tensorflow * /home/yc/anaconda3/envs/tensorflow
2.创建和移除Anaconda虚拟环境
创建命令
conda create --name tensorflow python=3.6.10
删除之前设置镜像的命令
conda config --remove channels 镜像名
显示已经设置的镜像名
conda config --show channels
添加新的镜像的命令(清华源)
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 config --add channels
https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels
https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
激活虚拟环境
conda activate tensorflow
关闭虚拟环境
conda deactivate
移除虚拟环境
conda remove -n tensorflow --all
3.查看自己所安装的CUDA版本
下面两个指令都可以(前提是添加了环境变量)
nvcc -V
nvcc --version
返回结果
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
4.安装TensorFlow 1.x
在创建环境之后输入命令(最好使用conda)
conda install tensorflow-gpu==1.14.0
用
5.安装和移除TensorFlow 2.x
安装不支持GPU的Tensorflow
pip install tensorflow
安装支持GPU的Tensorflow
pip install tensorflow-gpu
升级Tensorflow
pip install --upgrade tensorflow
pip install --upgrade tensorflow-gpu
移除Tensorflow
pip uninstall tensorflow