Tensorflow learning 1 – Installation without GPU on ubuntu 16.04
There are two ways of installing tensorflow on ubuntu, one is without GPU and the other is with NVIDIA GPU. Since I don’t have nvidia-gpu on my laptop, this article is about how to installation without GPU on ubuntu 16.04
Installation in python virtual environment
- set up python virtual environment
python apt-get install python-dev python-pip python-virtualenv - create a virtual environment for tensorflow and choose the version of python you want with the following command:
virtualenv --system-site-packages ~/tensorflow -p python3
ps: you also can choose python 2, which depends on which version you perfer - activate the virtual environment,
source ~/tensorflow/bin/activate
the command should change your prompt to the following:
(tensorflow)$ Issue the following command to install tensorflow in the active virtual environment
pip3 install --upgrade tensorflow
since we are using python3 for tensorflow, we have to usepip3.
Notice: you cannot usesudowith this command since we are in the virtual environment.To exit this environment,
(tensorflwo)$ deactivate
PS: For this way, we have to activate the virtual enviroment every single time with
source ~/tensorflow/bin/activateto use tensorflow. otherwise, tensorflwo is not available.- set up python virtual environment
Verify if tensorflow is installed properly
- activate virtual environment for tensorflow
source ~/tensorflow/bin/activate - invoke python from your shell as follows
python - Enter the following short program inside the python interactive shell:
>>> import tensorflow as tf
>>> hello = tf.constant(‘Hello, Tensorflow!’)
>>> sess = tf.Session()
>>> print(sess.run(hello))- activate virtual environment for tensorflow
- If the system outputs the following, then you are ready to write tensorflow programs:
Hellow, Tensorflow!
Congrats, you are able to use Tensorflow now! Start learning Tensorflow yourself.Sunday, 11. June 2017 04:49PM – Shuen
本文介绍如何在不带NVIDIA GPU的Ubuntu 16.04系统上安装TensorFlow。主要步骤包括设置Python虚拟环境、激活环境及使用pip3安装TensorFlow。最后通过运行示例程序验证TensorFlow是否安装成功。
1463

被折叠的 条评论
为什么被折叠?



