Training Tensorflow models on a NVIDIA GPU requires NVIDIA drivers, CUDA, and cuDNN. See here for the instructions to install all of these components on Ubuntu 18.04.
Building from source should led to faster training times. The easiest way to do this is with Docker. First we have to install some prerequisites:
- Install Docker CE using the repository (https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository)
- Post-installation steps for Linux (https://docs.docker.com/install/linux/linux-postinstall/)
- Install nvidia-docker (https://github.com/NVIDIA/nvidia-docker)
Finally, instructions for building Tensorflow with GPU-support from source using Docker can be found here.
Once you have built Tensorflow in the container, a Tensorflow package will be available in your home directory, for example: ~/tensorflow-version-cp35-cp35m-linux_x86_64.whl
.
You can then pip install
this version. For example, if you are using conda
to manage your virtual enviornments
$ conda activate myenv
(myenv) $ pip install ~/tensorflow-version-cp35-cp35m-linux_x86_64.whl