Public | Automated Build

Last pushed: 7 months ago
Short Description
A Docker image for GPU-enabled Keras.
Full Description


A Docker image for GPU-enabled Keras.


NVIDIA drivers, Docker and NVIDIA Docker for Ubuntu 16.04LTS are assumed to be properly installed.

If you are using a cloud compute instance with TensorFlow supported NVIDIA cards, e.g. Google Cloud Compute Instance or Amazon EC2 instance, you can simply install all dependencies by executing the following command from ternimal:

wget -O /tmp/
sudo bash /tmp/
rm /tmp/

Do not run this command if it is your own computer. It may cause incompatible driver problems. The above script also includes tools like vim, tmux, pip, etc. I found myself that these tools are very useful while doing a project with keras. You can of course modify the script if you don't need them.


Once all dependencies are properly installed, the docker image can be simply "installed" with command:

$ docker pull jihong/keras-gpu:latest

Note that this is also the command for upgrading.

Alternatively, one can directly run

$ nvidia-docker run -it --rm jihong/keras-gpu nvidia-smi

A docker pull will be automatically triggered by this command. This will show a summary table for the NVIDIA GPU status if the docker image is successfully running on your machine.


Launch bash within the container:

$ nvidia-docker run -it --rm jihong/keras-gpu bash

By default, this will use TensorFlow as backend. If you prefer theano as backend, you can add an environment variable with:

$ nvidia-docker run -it --rm -e KERAS_BACKEND='theano' jihong/keras-gpu bash

Mount a local directory to the container may be useful so that a local project can be running in the container:

$ nvidia-docker run -it --rm -v /path/to/directory/on/host:/root/workspace jihong/keras-gpu bash

where /path/to/directory/on/host is the absolute path of the project directory on host, and /workspace will be the name of your directory in the container.

Launch Jupyter notebook from the container:

$ nvidia-docker run -it --rm -p 8888:8888 -v /path/to/directory/on/host:/root/workspace jihong/keras-gpu
# jupyter notebook &

where -p 8888:8888 denotes the port mapping from host to container in the format of -p hostPort:containerPort.

Docker Pull Command
Source Repository