Full installation guide for TensorFlow, Keras, CUDA and cuDNN on Ubuntu 16.04 (64bit) with Python 3.5.
- GPU driver installation
- NVIDIA CUDA installation
- NVIDIA cuDNN installation
- TensorFlow installation
- Keras installation
GPU driver installation
Check for system updates and install them.
Open configuration for grub.
GRUB_CMDLINE_LINUX_DEFAULT and change it:
Save and close the file, then update grub settings.
We need to make sure there is no other installation of GPU driver and eventually remove it. Reboot your computer after this step.
Download from NVIDIA webpage correct driver for your card. Now make the
.run file executable.
Place these line at the end of the file, save and close.
Open putty terminal with
Ctrl + Alt + F1 and stop running graphical enviroment, so we can successfully install driver.
Open grub config again.
GRUB_CMDLINE_LINUX_DEFAULT and edit it.
Finally, update driver and restart your computer.
You should now have working driver for your graphic card.
NVIDIA CUDA installation
Download installation file, choose
deb (local) version and install it.
NVIDIA cuDNN installation
You need to register on NVIDIA website in order to download cuDNN. After your approval, download correct version of cuDNN (newest), which is compatible with your version of CUDA.
Unzip the archive and move files into the CUDA installation folder.
It is useful to add paths into bash settings. Open bash config file.
Put these lines at the end.
You need a Python installation before installing TensorFlow. If you do not have one yet, you can install Anaconda distribution, preferably with Python 3.5.
Open terminal and create new enviroment for TensorFlow installation.
Set URL for TensorFlow to download. This URL can be different for other versions. If you are not on 64bit version of Ubuntu, check line for TensorFlow original installation beneath.
And finally install TensorFlow.
This step is optional. Read more at Keras.io
You can install Keras from PyPI, so all you need to do is switch to tensorflow enviroment and install it using pip.
You now have installation of TensorFlow and Keras support GPU. When you want to use TensorFlow, type
source activate tensorflow into terminal,
source deactivate to switch back to default enviroment.
If you need to install new packages into this enviroment, use
conda install or
pip install. Remember that these packages will only be installed into currently used enviroment.
One useful thing when you use your graphic card is
nvidia-smi. It is a small CLI program, that let you monitor GPU utilization. Type
watch nvidia-smi into terminal and it will by updated every second.