Installing TensorFlow on Fedora 29
TF is an open source machine learning framework made by Google for everyone. Installing TensorFlow on Fedora 29 might seem hard but actually it isn’t a hard process at all.
More information about TF can be found at https://www.tensorflow.org/
Installation steps:
- Pip is not installed on fedora 29 so pip needs to be installed by running the command:
sudo dnf install python3-pip
2. Install virtualenv (the venv steps can be skipped in case of a system wide installation)
sudo pip3 install -U virtualenv
3. Creating the project directory
mkdir <name of project>
cd <name of project># Creates and changes the directory with any preffered name
4. Check python version
WARNING!
Before creating the virtual environment make sure Tensorflow supports the version of python you have installed on your OS.
Check installed python version by typing python --version
Check supported versions of python at https://www.tensorflow.org/install/pip at the bottom of the page.
In my case fedora 29 came with python 3.7 preinstalled and the latest supported version of python for tensorflow is 3.6 so I had to install python 3.6 by running:
sudo dnf install python36
5. Create Virtual environment
virtualenv —system-site-packages -p python<supported version you want to use> ./venv
so in my case:
virtualenv —system-site-packages -p python3.6 ./venv
6. Activate the virtualenv
source ./venv/bin/activate
you can also upgrade pip just to be sure everything works as expected
pip install --upgrade pip
7. Install tensorflow on the virtualenv
pip install tensorflow
8. Verify the installation
Now tensorflow should be installed in the virtualenv but to make sure it actually work let’s execute the command
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
The command should output somthing similar to this:
In case you get an warning about the CPU you can run this to ignore it.
python -c "import tensorflow as tf; import os; os.environ['TF_CPP_MIN_LOG_LEVEL'] = ‘2’; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
Now you can read the documentation of TensorFlow and start making some real projects.
9. To exit the virtualenv run
deactivate