This guide will help you install TensorFlow on your GNU/LINUX Mint machine.
You’ll need PYTHON and PIP
It’s likely you already have Python installed but you might not have pip (a package manager for Python that downloads and installs packages for you). Install pip by running the following command.
sudo apt-get install python-pip
If you already have it installed, you may need to update it.
sudo pip install --upgrade pip
Installing the tensorflow package normally might result in some of your default python installation being damaged due to libraries being overwritten by TensorFlow. The workaround is to useĀ VIRTUAL ENV.
sudo pip install virtualenv
Now we must create the folder for the TensorFlow virtual env
$ mkdir ~/venvs/ $ virtualenv ~/venvs/tensorflow
Turn on the new environment by using the source command. Install tensorflow package inside the virtualenv and exit using the deactivate command.
$ source ./venvs/tensorflow/bin/activate (tensorflow)$ pip install tensorflow (tensorflow)$ deactivate
Check if it installed. Copy the following code into a file and save it as test.py
import tensorflow as tf print(tf.__version__)
now run the above code
$ source ./venvs/tensorflow/bin/activate (tensorflow) $ python test.py 1.10.1
You can do a simple “Hi World” program using the following code
import tensorflow as tf h = tf.constant("Hi") w = tf.constant("world") hw = h + w with tf.Session() as sess: ans = sess.run(hw) print (ans)
Save as HiWorld.py and run
(tensorflow) $ python HiWorld.py HiWorld
Leave a comment