Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add a docker image for caffe development. #3518
Conversation
|
Thanks for the pointers, I will have a look at the best practices and adjust the docker file accordingly. The code to change the user started as a more general script, and I can try to simplify it to be better suited to the task of building caffe. In terms of usefulness, I use the image locally and thought I would submit it as a pull request so that it is part of caffe as it was also mentioned in #2313 (comment). If it is not found to be useful, we can close the pull request without merging, and I will move the utilities to its own repository. |
|
I just think there is a lot of code to set the user, it might scare Docker beginners. But don't get me wrong, I think this PR is very useful, the Caffe users list is full of topics where people are struggling to compile Caffe on their machine. You don't need to convince me of the benefits offered by Docker, but I'm not a maintainer of Caffe.
|
AwokeKnowing
commented
Jan 6, 2016
|
This is excellent. This will allow a reliable way to guide students through tutorials, as well as let programmers cleanly keep up to date with caffe releases as well as keep their scripts running on previous versions if breaking changes occur. Hopefully there will be a repository on dockerhub of images of past versions (from here on out). I hope the dockerfile can get some attention and get "generalized" or whatever it needs to be a standard way of using caffe. |
|
Given that there seems to be demand, what needs to be changed/added so that this is as useful as possible? Some thoughts:
Something that would be nice to have would be that the docker images be tagged using the Caffe version. What is the status of #3311? |
shelhamer
added enhancement community JD JL ES
labels
Jan 11, 2016
|
I think those are good ideas, I would keep things simple as a start, it will be easier for the project maintainers to review, especially if they don't have any prior experience with Docker. |
elezar
referenced
this pull request
Jan 15, 2016
Merged
Add library versioning and mark version 1.0.0-rc3 #3311
|
I have made some changes to the Dockerfiles. There are now two (CPU and GPU) Dockerfiles which provide runtime containers. These can be used as replacements for the caffe executable? I have also simplified the script for running the development container somewhat. I would appreciate input wrt finishing this pull request off? Does BVLC have a Docker Hub orgainisation, for example, so that we can set up triggered builds there? Are there any comments related to where the Dockerfiles are specified, and whether other flavors (e.g. OpenBLAS, CUDA 7.0, non-CUDNN) should be made available? |
|
I think this is a good start, I don't think other flavors are required right now. The benefit of Docker is to bundle all the dependencies, so for instance cuDNN is already included in the image. It will be transparent for users. I would use the cmake build system actually instead of having to copy |
|
Ok. I will switch the docker files to Any comments on the location of the docker files? Or are |
|
Regarding the location: ask the maintainers, they are all labeled to this PR so they will probably answer when they have the time :) |
|
@elezar Are you done working on this PR? If you're done let me know so I can review it again. @shelhamer: you tagged this PR, is Docker going to be on your roadmap in the future? |
|
From my side, the Docker images are done. If someone could check out the PR |
|
Please squash all your patches into one for easier review (see |
|
@flx42 I have squashed the changes, and tried to make the docker files more in keeping with the steps given on the installation website. I have also removed the additions (such as jupyter ports) which are not core to the requirements of the images. I have added Dockerfile generation options to the makefile (although they are themselves checked in) so that these are generated automatically from templates. This ensures that they are uniform, and adds some options in terms of extending these for future versions. |
jeffdonahue
and 2 others
commented on an outdated diff
Feb 12, 2016
| +# Use --no-install-recommends for the boost libs. | ||
| +RUN apt-get install -y --no-install-recommends \ | ||
| + libboost-all-dev | ||
| + | ||
| +# Install utilities used for the build. | ||
| +RUN apt-get install -y \ | ||
| + build-essential \ | ||
| + cmake \ | ||
| + cmake-curses-gui \ | ||
| + git \ | ||
| + ca-certificates \ | ||
| + bc \ | ||
| + wget | ||
| + | ||
| +# Install the python requirements. | ||
| +RUN wget https://raw.githubusercontent.com/BVLC/caffe/master/python/requirements.txt -O /tmp/requirements.txt && \ |
jeffdonahue
Contributor
|
seanbell
commented on an outdated diff
Feb 13, 2016
| + ca-certificates \ | ||
| + bc \ | ||
| + wget | ||
| + | ||
| +# Install the python requirements. | ||
| +RUN wget https://raw.githubusercontent.com/BVLC/caffe/master/python/requirements.txt -O /tmp/requirements.txt && \ | ||
| + cat /tmp/requirements.txt && \ | ||
| + cat /tmp/requirements.txt | xargs -n1 pip install | ||
| + | ||
| +# Clean up the apt-get cache and remove unused packages. | ||
| +RUN apt-get clean \ | ||
| + && rm -rf /var/lib/apt/lists/* | ||
| + | ||
| +CMD bash | ||
| +# Clone Caffe repo and move into it | ||
| +RUN cd /opt && git clone https://github.com/BVLC/caffe.git && cd caffe && \ |
seanbell
Contributor
|
seanbell
commented on an outdated diff
Feb 13, 2016
| + ca-certificates \ | ||
| + bc \ | ||
| + wget | ||
| + | ||
| +# Install the python requirements. | ||
| +RUN wget https://raw.githubusercontent.com/BVLC/caffe/master/python/requirements.txt -O /tmp/requirements.txt && \ | ||
| + cat /tmp/requirements.txt && \ | ||
| + cat /tmp/requirements.txt | xargs -n1 pip install | ||
| + | ||
| +# Clean up the apt-get cache and remove unused packages. | ||
| +RUN apt-get clean \ | ||
| + && rm -rf /var/lib/apt/lists/* | ||
| + | ||
| +CMD bash | ||
| +# Clone Caffe repo and move into it | ||
| +RUN cd /opt && git clone https://github.com/BVLC/caffe.git && cd caffe && \ |
seanbell
Contributor
|
|
@elezar How do you see these images as being used? I understand that you want to create a canonical version that uses the official master-branch code, but I don't the proposed code achieves that. The way it is written, the I agree that for development you want to mount in the source code, and that is indeed helpful. But for everything else that gets copied into the image itself, I think Alternatively, if you really want to use |
|
Thank you for joining the debate, @seanbell! Disclaimer: if you don't know, I'm a maintainer of https://github.com/NVIDIA/nvidia-docker Let's merge the answers into the main thread.
Not with his approach, he wants users to compile Caffe after shelling inside the container.
I think this use case is more suited to the "devel" image. The runtime image is precisely for people that don't want to do that. They want to start using Caffe, or they are already advanced users but they don't have custom layers. People do use deb packages sometimes, right? :) An advantage of this self-contained approach is that you don't need to clone the code, you can build a Dockerfile from GitHub directly:
I like the convenience of avoiding to copy the whole repo on my local file system. And the point of this runtime image is to rely on a pristine, well-tested version, you don't want to @seanbell, what you suggest sounds fine for the Retrospectively, I think it might be better to start simple by only including the runtime images in this PR. This would be sufficient for caffe newcomers during hands-on tutorials. |
|
Thanks for the comments @seanbell, and also the nice summary of the use cases @flx42. I think you may be right in suggesting that this pull request only include the runtime images. This is the use case that probably caters most to the target audience. That is to say people who want to quickly try caffe, or for a sort of archiving for particular versions. I will remove the other files for the time being and add them as a separate pull request (I should still be able to address my own use-case with some shell scripts, although the images may be larger than needed). With regards to:
Yes, that is true. I do have the following to add: |
As I'm still unfamiliar with Docker and would like to include an out-of-the-box method to run Caffe I like the suggestion of splitting off the dev image and focusing on the runtime image in this PR. The dev image seems useful in itself, but new users do need the most help and it sounds like it will be easier to review (giving me more time to get up to speed with Docker and figure out the dev image). Thanks for the work on this @elezar, the perspective @flx42, and the review @seanbell! |
|
I have removed the development images from this pull request (I will create a new pull request for this as soon as I get a chance). @seanbell, I have not yet addressed your concerns with regards to the clone command in the Dockerfile. Suggestions would be welcome. |
|
Also, maybe we can find a better name than |
|
Maybe |
|
We're almost there I think, here's what I suggest:
I verified it briefly, it seems to work. |
|
Thanks for the comments. I have updated the Dockerfiles accordingly. Some notes that I would like to add:
I don't feel that strongly about these though, and since they can both be addressed from the command line, I am willing to make the changes if they are preferred. |
|
Alright, let's see if someone else has an opinion on the entrypoint. |
|
Thanks! @seanbell and @shelhamer do you have any final comments then? |
seanbell
commented on an outdated diff
Feb 17, 2016
seanbell
commented on an outdated diff
Feb 17, 2016
| @@ -0,0 +1,46 @@ | ||
| +# Caffe standalone Dockerfiles. | ||
| + | ||
| +The `standalone` subfolder contains docker files for generating both CPU and GPU executable images for Caffe. The images can be built using make, or by running: | ||
| + | ||
| +``` | ||
| +docker build -t caffe standalone/gpu |
seanbell
Contributor
|
seanbell
commented on an outdated diff
Feb 17, 2016
| +The `standalone` subfolder contains docker files for generating both CPU and GPU executable images for Caffe. The images can be built using make, or by running: | ||
| + | ||
| +``` | ||
| +docker build -t caffe standalone/gpu | ||
| +``` | ||
| +for example. | ||
| + | ||
| +Note that the GPU standalone requires a CUDA 7.5 capable driver to be installed on the system and [nvidia-docker|https://github.com/NVIDIA/nvidia-docker] for running the Docker containers. | ||
| + | ||
| +# Running Caffe using the docker image | ||
| + | ||
| +In order to test the Caffe image, run: | ||
| +``` | ||
| +docker run -ti caffe --version | ||
| +``` | ||
| +or |
seanbell
Contributor
|
|
Sorry for the delay in replying. Regarding entrypoint/workdir: That being said, I'm okay with keeping in the entrypoint as long as it's explained in the README (e.g. what to do if you want another command like Regarding
@flx42 Regarding @fix42 regarding "And the point of this runtime image is to rely on a pristine, well-tested version, you don't want to ADD your local changes by mistake.", I think that using docker hub addresses that concern. The pristine well-tested version is the remote artifact. I still think that using |
|
I think the PR is currently building the bleeding-edge version as a placeholder, we really need Caffe to tag version |
|
Thanks for all the comments @seanbell (and @flx42) again. I have tried to clean up the readme, and to use the tags ( With regards to the cloning and building a specific branch, I have added a docker build arg ( |
|
It would be good to merge the Otherwise, this looks good to me! Thanks for all the changes. |
AwokeKnowing
commented
Feb 19, 2016
|
Hi guys, I sooo glad the docker solution is being implemented. I am the "new guy who just wants to try out caffee" use case. The workflow I expect to use is like this:
Is there yet a tutorial example of doing that with docker (ubuntu 14.04)? What I want is to NOT install caffe on any computer. In fact, I don't want to install the CUDA toolkit or anything else. Only have the layers/scripts + docker image. |
|
@seanbell I have now moved the pydot install to the point where the requirements file is processed. @AwokeKnowing It sounds as if the images would be useful for your use case. If you want to look at how the images can be used to train a model, the pull request includes an mnist example at |
|
If everyone's happy with the current state, then the next step is to squash everything into a single commit, for a clean git history. @shelhamer any other comments? |
|
Sure. As soon as I get the go-ahead, I will squash and push again. (by the way, it seems as if DockerHub does not yet support the |
shelhamer
commented on an outdated diff
Feb 19, 2016
| @@ -0,0 +1,44 @@ | ||
| +FROM ubuntu:14.04 | ||
| +#MAINTAINER fixme@example.com |
shelhamer
Owner
|
shelhamer
commented on an outdated diff
Feb 19, 2016
| @@ -0,0 +1,33 @@ | ||
| +#!/usr/bin/env sh | ||
| +set -e | ||
| +# The following example allows for the MNIST example (using LeNet) to be run | ||
| +# using the caffe docker image instead of building from source. | ||
| +# The GPU-enabled version of Caffe can be used, assuming that nvidia-docker | ||
| +# is installed, and the GPU-enabled Caffe image has been built. | ||
| +# Setting the GPU environment variable to 1 will enable the use of nvidia-docker. | ||
| +# e.g. | ||
| +# GPU=1 ./examples/mnist/train_lenet_docker.sh | ||
| +# | ||
| +# Not the use of the -u, -v, and -w command line options to ensure that |
|
|
shelhamer
and 1 other
commented on an outdated diff
Feb 19, 2016
| +then | ||
| +DOCKER_CMD=nvidia-docker | ||
| +IMAGE=caffe:gpu | ||
| +else | ||
| +DOCKER_CMD=docker | ||
| +IMAGE=caffe:cpu | ||
| +fi | ||
| + | ||
| +echo "Using $DOCKER_CMD to launch $IMAGE" | ||
| + | ||
| +$DOCKER_CMD run --rm -ti \ | ||
| + -u $(id -u):$(id -g) \ | ||
| + -v $(pwd):/workspace \ | ||
| + -w /workspace \ | ||
| + $IMAGE \ | ||
| + caffe train --solver=examples/mnist/lenet_solver.prototxt $* |
shelhamer
Owner
|
@elezar right, I just had this issue in trying to use the Thanks! |
|
While addressing some of the last comments by @shelhamer I noted the following:
When running an operation that creates an LMDB env (for reading OR writing) in a path rooted at a host volume, the following error is shown (for
and for
When performing both these operations in a non host-mapped path they are successful, and one is also able to copy any generated data to the host path successfully. I should add that I don't think this is caffe-specific, and I have just tried something similar with the NVIDIA DIGITS image. That is to say, when I run:
The creation of the LMDB database fails with the following log output:
@flx42 have you come across something like this before? I have tested the DIGITS commands previously on a Linux system at work, with no problems there. I will then test the scripts that I have been working on to ensure that they work on Linux, before pushing them. We can then discuss what our options are for OS X. |
shelhamer
commented on an outdated diff
Feb 20, 2016
| @@ -0,0 +1,52 @@ | ||
| +# Caffe standalone Dockerfiles. | ||
| + | ||
| +The `standalone` subfolder contains docker files for generating both CPU and GPU executable images for Caffe. The images can be built using make, or by running: | ||
| + | ||
| +``` | ||
| +docker build -t caffe:cpu standalone/cpu | ||
| +``` | ||
| +for example. (Here `gpu` can be substituted for `cpu`, but to keep the readme simple, only the `cpu` case will be discussed in detail). | ||
| + | ||
| +Note that the GPU standalone requires a CUDA 7.5 capable driver to be installed on the system and [nvidia-docker|https://github.com/NVIDIA/nvidia-docker] for running the Docker containers. Here it is generally sufficient to user `nvidia-docker` instead of `docker` in any of the commands mentioned. |
|
|
|
I just realized that this will do the most good if it's highlighted in the installation docs defined by |
|
@shelhamer Sure, I will update the docs too. Could you (and @flx42 and @seanbell) have a look at the updated Note that the script works under Linux, but after the trouble I had under OSX over the weekend, I don't expect it to be so simple there (or under Windows). I will have to come up with a better solution there, but would like to get this PR in before investigating that further. On a side note, I am currently building this branch at https://hub.docker.com/r/elezar/caffe but it may be a good idea to get this setup so that the image is associated with a BVLC account. In this case, we can change the script to use a |
flx42
commented on an outdated diff
Feb 24, 2016
| @@ -0,0 +1,52 @@ | ||
| +# Caffe standalone Dockerfiles. | ||
| + | ||
| +The `standalone` subfolder contains docker files for generating both CPU and GPU executable images for Caffe. The images can be built using make, or by running: | ||
| + | ||
| +``` | ||
| +docker build -t caffe:cpu standalone/cpu | ||
| +``` | ||
| +for example. (Here `gpu` can be substituted for `cpu`, but to keep the readme simple, only the `cpu` case will be discussed in detail). | ||
| + | ||
| +Note that the GPU standalone requires a CUDA 7.5 capable driver to be installed on the system and [nvidia-docker|https://github.com/NVIDIA/nvidia-docker] for running the Docker containers. Here it is generally sufficient to use `nvidia-docker` instead of `docker` in any of the commands mentioned. |
|
|
flx42
commented on an outdated diff
Feb 24, 2016
| + libprotobuf-dev \ | ||
| + libsnappy-dev \ | ||
| + protobuf-compiler \ | ||
| + python-dev \ | ||
| + python-numpy \ | ||
| + python-pip \ | ||
| + python-scipy && \ | ||
| + rm -rf /var/lib/apt/lists/* | ||
| + | ||
| +ENV CAFFE_ROOT=/opt/caffe | ||
| +WORKDIR $CAFFE_ROOT | ||
| + | ||
| +# FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. | ||
| +ENV CLONE_TAG=master | ||
| + | ||
| +RUN git clone -b ${CLONE_TAG} --single-branch --depth 1 https://github.com/BVLC/caffe.git . && \ |
flx42
Contributor
|
flx42
commented on an outdated diff
Feb 24, 2016
| + python-pip \ | ||
| + python-scipy && \ | ||
| + rm -rf /var/lib/apt/lists/* | ||
| + | ||
| +ENV CAFFE_ROOT=/opt/caffe | ||
| +WORKDIR $CAFFE_ROOT | ||
| + | ||
| +# FIXME: clone a specific git tag and use ARG instead of ENV once DockerHub supports this. | ||
| +ENV CLONE_TAG=master | ||
| + | ||
| +RUN git clone -b ${CLONE_TAG} --single-branch --depth 1 https://github.com/BVLC/caffe.git . && \ | ||
| + for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \ | ||
| + mkdir build && cd build && \ | ||
| + cmake ${CMAKE_ARGS} .. && \ | ||
| + make -j"$(nproc)" all && \ | ||
| + make -j"$(nproc)" pycaffe |
flx42
Contributor
|
This was referenced Feb 25, 2016
|
Should I squash the commits so that this can be merged? I can then update the docs, and use the standalone images as a basis for other development utilities. |
|
On my side, the PR looks good know. But I didn't have time to extensively test the images, mind you. |
|
I have squashed the commit. |
|
I was able to build the However, the LeNet docker example fails because nvidia-docker neither recognizes Here is an example call
that ran fine. |
|
@shelhamer Yeah that's a bug in |
|
Alright, well I'm happy to merge once the example works whether by long options in this PR or a fix to nvidia-docker. @elezar feel free to force push an amended commit. (If you do amend, consider formatting the commit message so it has a "title" line <80 chars and then further description after a newline as it formats better on the command line and on github, but no worries.) |
|
I have switched to the |
shelhamer
added a commit
that referenced
this pull request
Feb 27, 2016
|
|
shelhamer |
59d099c
|
shelhamer
merged commit 59d099c
into
BVLC:master
Feb 27, 2016
1 check passed
|
Thanks for the Caffe containers @elezar ! Next we'll figure out how to include these on the docker hub. |
shelhamer
added a commit
to shelhamer/caffe
that referenced
this pull request
Feb 27, 2016
|
|
shelhamer |
cfa2c0c
|
shelhamer
added a commit
that referenced
this pull request
Feb 27, 2016
|
|
shelhamer |
04aa36e
|
|
Thank you for the additional fix @shelhamer, this bug is embarrassing for us, we will fix it quickly. |
elezar
deleted the
elezar:feature/docker_images branch
Feb 28, 2016
|
Thanks @shelhamer. As for getting the images onto Docker Hub, I see two options. Either one sets up an automated build on Docker Hub itself (I have already done this for https://hub.docker.com/r/elezar/caffe), or one builds the images as part of some CI/CD steps and pushes them. I think the latter is the route that NVIDIA follows for https://hub.docker.com/r/nvidia/. Maybe @flx42 could comment on this? I should add that for the automated builds on Docker Hub seem to be failing for the GPU images (with no log output). @flx42 do you have an idea what the reason for this may be? |
|
@elezar: we tried using the automated build on the DockerHub but we gave up on this idea because it was not suitable for our complex model with multiple images (see the discussion here). I don't know why it would fail on the Docker Hub, it used to work when I tested. |
BlGene
added a commit
to BlGene/caffe
that referenced
this pull request
Feb 29, 2016
|
|
shelhamer + BlGene |
5bc9aaa
|
BlGene
added a commit
to BlGene/caffe
that referenced
this pull request
Mar 4, 2016
|
|
shelhamer + BlGene |
06690ff
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Mar 17, 2016
|
|
shelhamer + zouxiaochuan |
4ca67f2
|
jakirkham
commented on docker/standalone/gpu/Dockerfile in 6cba462
Mar 18, 2016
|
Is |
|
Wget is used in some of the scripts for downloading datasets (e.g. MNIST).
…
|
jakirkham
replied
Mar 20, 2016
|
Ok, thanks for clarifying. Is there a way of disabling this download? I imagine these datasets can get quite big depending on how much you are including. |
jakirkham
commented on docker/standalone/gpu/Dockerfile in 6cba462
Mar 22, 2016
|
I noticed here that |
|
I think graphviz may be installed as part of the base image. Pydot is used
in the network visualisation tool.
…
|
SvenTwo
added a commit
to SvenTwo/caffe
that referenced
this pull request
Apr 6, 2016
|
|
shelhamer + SvenTwo |
f6c4879
|
fxbit
added a commit
to Yodigram/caffe
that referenced
this pull request
Sep 1, 2016
|
|
shelhamer + fxbit |
94c4db6
|
fxbit
added a commit
to Yodigram/caffe
that referenced
this pull request
Sep 1, 2016
|
|
shelhamer + fxbit |
4a75fa9
|
fxbit
added a commit
to Yodigram/caffe
that referenced
this pull request
Sep 1, 2016
|
|
shelhamer + fxbit |
8ebb8bf
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Oct 24, 2016
|
|
shelhamer + zouxiaochuan |
a175281
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Oct 24, 2016
|
|
shelhamer + zouxiaochuan |
0770031
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Feb 15, 2017
|
|
shelhamer + zouxiaochuan |
f9658a6
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Feb 15, 2017
|
|
shelhamer + zouxiaochuan |
844f732
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Feb 15, 2017
|
|
shelhamer + zouxiaochuan |
7f1dc98
|
zouxiaochuan
added a commit
to zouxiaochuan/caffe
that referenced
this pull request
Feb 15, 2017
|
|
shelhamer + zouxiaochuan |
029f431
|
elezar commentedJan 5, 2016
The idea is to add docker files for Caffe. Both for development purposes (my original motivation) and for providing pre-built Caffe images. The following steps can be considered: