install tensorflow
安装
安装 anaconda
-
下载
- 安装
caohm@caohm-ThinkPad-E450:~$ bash Anaconda3-2018.12-Linux-x86_64.sh
- 加入环境变量
caohm@caohm-ThinkPad-E450:~$ vi .bashrc #添加 export PATH=/home/caohm/anaconda3/bin:$PATH
- 生效
caohm@caohm-ThinkPad-E450:~$ source ~/.bashrc
- 检测
caohm@caohm-ThinkPad-E450:~$ conda --version conda 4.5.12 #查看软件列表 caohm@caohm-ThinkPad-E450:~$ conda list #安装软件 caohm@caohm-ThinkPad-E450:~$ conda install * #更新软件 caohm@caohm-ThinkPad-E450:~$ conda update *
- 升级
caohm@caohm-ThinkPad-E450:~$ bash Anaconda3-2018.12-Linux-x86_64.sh -u
- 卸载
caohm@caohm-ThinkPad-E450:~$ rm -rf ~/anaconda3
安装 tensorflow
建立专门的运行环境再安装 可以专门建立一个tensorflow的运行环境,好处是:1.官网建议 2.不与其他文件混乱
-
创建专门运行环境
为Anaconda创建一个python3.6(或者3.5都行,随便)的环境,环境名称为tensorflow ,输入下面命令:
caohm@caohm-ThinkPad-E450:~$ conda create -n tensorflow python=3.6 caohm@caohm-ThinkPad-E450:~$ conda info --envs #查看python版本 caohm@caohm-ThinkPad-E450:~$ python --version
-
启动tensorflow的环境:
caohm@caohm-ThinkPad-E450:~$ conda activate tensorflow
注:当不使用tensorflow时,关闭tensorflow环境,命令为:
(tensorflow) caohm@caohm-ThinkPad-E450:~$ conda deactivate
- 安装cpu版本的TensorFlow
(tensorflow) caohm@caohm-ThinkPad-E450:~$ pip install --upgrade --ignore-installed tensorflow
-
测试是否安装完成
(tensorflow) caohm@caohm-ThinkPad-E450:~$ python >>> import tensorflow as tf >>> tf.enable_eager_execution() >>> tf.add(1, 2).numpy() 3 >>> hello = tf.constant('Hello, TensorFlow!') >>> hello.numpy() 'Hello, TensorFlow!'
Hello World