Skip to content

Commit

Permalink
Use cmake instead of modifying Makefile.config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Lezar committed Jan 29, 2016
1 parent 6546ca7 commit c03732c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ all:
.PHONY: cpu_runtime gpu_runtime devel

cpu_runtime:
docker build -t caffe:runtime runtime/cpu
docker build -t caffe runtime/cpu

gpu_runtime:
docker build -t caffe:runtime runtime/gpu
docker build -t caffe:gpu runtime/gpu

devel:
docker build -t caffe:devel devel
5 changes: 5 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ libdc1394 error: Failed to initialize libdc1394
caffe version 1.0.0-rc3
```

One can also run the caffe tests using:
```
docker run -ti --entrypoint=/usr/bin/bash caffe -c "cd /opt/caffe/build; make runtest"
```

In order to get the most out of the caffe image, some more advanced `docker run` could be used. For example, running:
```
docker run -ti -v $(pwd):/workspace caffe train --solver=example_solver.prototxt
Expand Down
17 changes: 9 additions & 8 deletions docker/runtime/cpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ RUN apt-get update \

# Clone Caffe repo and move into it
RUN cd /opt && git clone https://github.com/BVLC/caffe.git && cd caffe && \
# Copy Makefile
cp Makefile.config.example Makefile.config && \
# Enable CUDNN:
# sed -i 's/# USE_CUDNN/USE_CUDNN/g' Makefile.config && \
# Enable CPU-only
sed -i 's/# CPU_ONLY/CPU_ONLY/g' Makefile.config && \
# Create a build directory
mkdir build && cd build && \
# Run cmake
cmake -DCPU_ONLY=1 .. &&\
# # Make
make -j"$(nproc)" all && \
make -j"$(nproc)" pycaffe
make -j"$(nproc)" all && \
make -j"$(nproc)" pycaffe

# Also build some other utility targets.
RUN cd /opt/caffe/build && make -j"$(nproc)" test.testbin


# Add to Python path
Expand Down
19 changes: 10 additions & 9 deletions docker/runtime/gpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ RUN apt-get update \

# Clone Caffe repo and move into it
RUN cd /opt && git clone https://github.com/BVLC/caffe.git && cd caffe && \
# Copy Makefile
cp Makefile.config.example Makefile.config && \
# Enable CUDNN:
sed -i 's/# USE_CUDNN/USE_CUDNN/g' Makefile.config && \
# Enable CPU-only
# sed -i 's/# CPU_ONLY/CPU_ONLY/g' Makefile.config && \
# Make
make -j"$(nproc)" all && \
make -j"$(nproc)" pycaffe
# Create a build directory
mkdir build && cd build && \
# Run cmake
cmake -DUSE_CUDNN=1 .. &&\
# # Make
make -j"$(nproc)" all && \
make -j"$(nproc)" pycaffe

# Also build some other utility targets.
RUN cd /opt/caffe/build && make -j"$(nproc)" test.testbin


# Add to Python path
Expand Down
12 changes: 12 additions & 0 deletions examples/mnist/train_lenet_docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/usr/bin/env sh
# 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
# files are created under the ownership of the current user, and in the
# current directory.

if [ $GPU -ne 1 ]
then
DOCKER_CMD=docker
Expand Down

0 comments on commit c03732c

Please sign in to comment.