-
Notifications
You must be signed in to change notification settings - Fork 19.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker image for test and experiment Keras #3035
Conversation
- Docker image with CUDA support on ubuntu 14.04 - nvidia-docker script to forward the GPU to the container - MakeFile to simplify docker commands for build, run, test, ..etc - Add useful tools like jupyter notebook, ipdb, sklearn for experiments
pip install theano ipdb pytest pytest-cov python-coveralls pytest-xdist pep8 pytest-pep8 && \ | ||
conda clean -yt | ||
|
||
ENV THEANO_FLAGS='mode=FAST_RUN,device=gpu,nvcc.fastmath=True,floatX=float32' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not echo a .theanorc file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just picked the first method in the docs: https://github.com/fchollet/keras/blob/master/docs/templates/getting-started/faq.md#how-can-i-run-keras-on-gpu
Do you prefer .theanorc ?
Nice addition! Should you update the makefile so it can be used with the nvidia-docker plugin? |
|
@@ -0,0 +1,52 @@ | |||
FROM nvidia/cuda:7.5-cudnn4-devel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cuDNN v5 is available 😃 :
FROM nvidia/cuda:7.5-cudnn5-devel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And quite a bit faster too!
Can someone more familiar with Docker than me review this? |
I can suggest some small changes but it would be good to have a third pass just to be sure everything is good! Another point, @dosht did you tried to launch the tests using Theano and TensorFlow in the container? |
pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0rc0-cp35-cp35m-linux_x86_64.whl && \ | ||
pip install git+git://github.com/Theano/Theano.git && \ | ||
pip install ipdb pytest pytest-cov python-coveralls coverage==3.7.1 pytest-xdist pep8 pytest-pep8 && \ | ||
conda install Pillow scikit-learn notebook pandas matplotlib nose pyyaml six h5py && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to install the libhdf5-dev
deb package for h5py to work properly?
Conda will link the compiled binaries but you will maybe have an error because the underlying c library is not there.
Why do you use conda to install python? |
@tboquet When running the tests, I got some failures. most of them are method not found.
|
Consider moving the two files to a Would you consider authoring a blog post on blog.keras.io to explain how to use this Docker image? |
@fchollet I moved the docker into a subdirectory and will write a blog post draft soon. |
@dosht conda is used on travis for the tests, it would be consistent to use it in your container as well. I will try to run the tests and compare the behaviour with some of my containers. In my previous comment I mentioned Windows. Making the container work on either a Linux distro or Windows is not trivial using their new native application or the vm. I thought it would be possible using the REST api but it's not the best way to use the plugin and it will become messy. Another point, it would be neat to have an automated build on Dockerhub 😃 . |
@@ -1,4 +1,4 @@ | |||
FROM nvidia/cuda:7.5-cudnn4-devel | |||
FROM nvidia/cuda:7.5-cudnn5-devel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dosht Have you tested if TensorFlow installed from the package (.whl) working with CuDNN 5? It's stated in TF docs that:
The GPU version (Linux only) works best with Cuda Toolkit 7.5 and cuDNN v4. other versions are supported (Cuda toolkit >= 7.0 and cuDNN 6.5(v2), 7.0(v3), v5) only when installing from sources.
(see https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#requirements).
@dosht
|
@tboquet, I added this repo on DockerHub: https://hub.docker.com/r/dosht/keras/, but the namespace will change later of course. @lukovkin, Starting from TensorFlow image is a good idea, but it's still using cudNN4. What do you think about that? |
@fchollet, I added a readme file to describe how it works and this might change after the automated build on DockerHub and if we will use docker compose instead of make. I will convert the readme into a blog post when this PR is done. |
@dosht sounds good. There seems to be multiple typos in the README, please have someone proofread it. |
@lukovkin, @tboquet, @henry0312 what do you guys think, are we all clear here? |
# Python | ||
ARG python_version=3.5.1 | ||
RUN conda install -y python=${python_version} && \ | ||
pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0rc0-cp35-cp35m-linux_x86_64.whl && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to define the version of tensorflow before the line, i guess.
@dosht By the way, how do you install keras in your Dockerfile? |
RUN conda install -y python=${python_version} && \ | ||
pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0rc0-cp35-cp35m-linux_x86_64.whl && \ | ||
pip install git+git://github.com/Theano/Theano.git && \ | ||
pip install ipdb pytest pytest-cov python-coveralls coverage==3.7.1 pytest-xdist pep8 pytest-pep8 && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip install git+git://github.com/fchollet/keras.git
is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking not to use install Keras, but to use current Keras code by append it to PYTHON_PATH
ENV PYTHONPATH='/src/:$PYTHONPATH'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it.
For visualization, pip install pydot_ng
sudo apt-get install graphviz may be needed? |
I have developed and am using a set of Keras Docker containers for some time now. The philosophy is to make it simple to understand (no make files or nvidia-docker dependencies), tags for all possible versions and variants (Python 2/3, Theano/TensorFlow, CPU/GPU), and to have minimal images (for production use) and a full image with all batteries included (jupyter, ipython). All containers are managed only with the basic For example for quick experiments and development of a model, one would mount his # for python 2
$ docker run -it --rm -v=/home/user/project1:/srv gw000/keras-full ipython2
# for python 3
$ docker run -it --rm -v=/home/user/project1:/srv gw000/keras-full ipython3 Or start a Jupyter Notebook in background accessible on $ docker run -d --name keras-full -p=6006:6006 -p=8888:8888 -v=/home/user/project1:/srv gw000/keras-full For an already developed Keras model that is ready for production, one would specify the exact version, backend, and device to use (so that it is reproducible and known environment): $ docker run -d --name project1 -v /srv/project1:/srv/project1 gw000/keras:1.0.4-py2-tf-cpu /srv/project1/run.py For more complex projects a Dockerfile can simply extend this minimal image to add its dependencies (this is the Docker-way of customizing things).:
In Dockerfiles all packages are installed using pip (not conda), because Python users most commonly use this. There are also automatic builds set up on Dockerhub. I am prepared to merge and maintain this in the main Keras repository. |
@fchollet looks good to me! @gw0, nice work! I like the way you handle Keras' versions. |
Sounds good to me. I like the ability to specify versions to create a production-safe image. |
Will merge after latest comments have been addressed. |
Yes, the
In my opinion things should be as understandable and easy to use/extend as possible. Sorry, but using a |
I understand your concern about the makefile. It's possible to modify this after this PR is merged. It's also possible to use the rest api of the plugin with the docker command. Relying on custom made cuda images is also a limitation since someone as to do the support for other os too. It's also difficult to support because nvidia is iterating a lot on cuda and cudnn. Theano is using nividia's repo and TensorFlow too. You should definitely integrate your ideas in the repo and a discussion has to be opened on the technologies to use. |
LGTM, though I don't know it's useful to use |
@henry0312 I was thinking to do that to make it easy to modify and experiment Keras code itself. |
LGTM |
I don't think cudnn5 is a good idea. below is a simple tf example. EDIT: @dosht I build docker with 7.5 cudnn4 from nvidia and its fine! better update Dockerfile
|
To avoid issues in installing Theano or CUDA in any Linux distros, This PR is to automate the environment with a docker image for Keras and CUDA that can share the GPUs with the docker container by an Nvidia's script.
The MakeFile is optional to make docker commands easier, e.g.
This can be more customizable by choosing a specific GPU and a directory for dataset, e.g.
I'm using this already for a while and it makes my life easier and will update the README as well if you liked this suggestion.
Thanks,