Skip to content

Commit 40d28e2

Browse files
authored
Merge pull request tensorflow#5116 from caisq/r0.11-fixes
Fixes and improvements to docker build script and dockerfiles
2 parents 671f4c6 + f41daaa commit 40d28e2

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

tensorflow/tools/docker/Dockerfile.devel

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
build-essential \
77
curl \
88
git \
9+
libcurl3-dev \
910
libfreetype6-dev \
1011
libpng12-dev \
1112
libzmq3-dev \
@@ -65,7 +66,7 @@ RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
6566
>>/root/.bazelrc
6667
ENV BAZELRC /root/.bazelrc
6768
# Install the most recent bazel release.
68-
ENV BAZEL_VERSION 0.3.1
69+
ENV BAZEL_VERSION 0.3.2
6970
WORKDIR /
7071
RUN mkdir /bazel && \
7172
cd /bazel && \
@@ -78,7 +79,7 @@ RUN mkdir /bazel && \
7879

7980
# Download and build TensorFlow.
8081

81-
RUN git clone --recursive https://github.com/tensorflow/tensorflow.git && \
82+
RUN git clone https://github.com/tensorflow/tensorflow.git && \
8283
cd tensorflow && \
8384
git checkout r0.11
8485
WORKDIR /tensorflow
@@ -87,10 +88,13 @@ WORKDIR /tensorflow
8788
# more difficult to experiment with local changes. Instead, just add
8889
# the built directory to the path.
8990

90-
RUN ./configure && \
91+
RUN tensorflow/tools/ci_build/builds/configured CPU \
9192
bazel build -c opt tensorflow/tools/pip_package:build_pip_package && \
9293
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip && \
93-
pip install --upgrade /tmp/pip/tensorflow-*.whl
94+
pip install --upgrade /tmp/pip/tensorflow-*.whl && \
95+
rm -rf /tmp/pip && \
96+
rm -rf /root/.cache
97+
# Clean up pip wheel and Bazel cache when done.
9498

9599
# TensorBoard
96100
EXPOSE 6006

tensorflow/tools/docker/Dockerfile.devel-gpu

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
66
build-essential \
77
curl \
88
git \
9+
libcurl3-dev \
910
libfreetype6-dev \
1011
libpng12-dev \
1112
libzmq3-dev \
@@ -31,6 +32,8 @@ RUN pip --no-cache-dir install \
3132
jupyter \
3233
matplotlib \
3334
numpy \
35+
scipy \
36+
sklearn \
3437
&& \
3538
python -m ipykernel.kernelspec
3639

@@ -66,7 +69,7 @@ RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
6669
>>/root/.bazelrc
6770
ENV BAZELRC /root/.bazelrc
6871
# Install the most recent bazel release.
69-
ENV BAZEL_VERSION 0.3.1
72+
ENV BAZEL_VERSION 0.3.2
7073
WORKDIR /
7174
RUN mkdir /bazel && \
7275
cd /bazel && \
@@ -79,7 +82,7 @@ RUN mkdir /bazel && \
7982

8083
# Download and build TensorFlow.
8184

82-
RUN git clone -b r0.11 --recursive --recurse-submodules https://github.com/tensorflow/tensorflow.git && \
85+
RUN git clone https://github.com/tensorflow/tensorflow.git && \
8386
cd tensorflow && \
8487
git checkout r0.11
8588
WORKDIR /tensorflow
@@ -89,10 +92,13 @@ ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
8992
ENV TF_NEED_CUDA 1
9093
ENV TF_CUDA_COMPUTE_CAPABILITIES=3.0,3.5,5.2
9194

92-
RUN ./configure && \
95+
RUN tensorflow/tools/ci_build/builds/configured GPU \
9396
bazel build -c opt --config=cuda tensorflow/tools/pip_package:build_pip_package && \
9497
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip && \
95-
pip install --upgrade /tmp/pip/tensorflow-*.whl
98+
pip install --upgrade /tmp/pip/tensorflow-*.whl && \
99+
rm -rf /tmp/pip && \
100+
rm -rf /root/.cache
101+
# Clean up pip wheel and Bazel cache when done.
96102

97103
WORKDIR /root
98104

tensorflow/tools/docker/parameterized_docker_build.sh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ else
120120
fi
121121

122122
if [[ ${TF_DOCKER_BUILD_TYPE} == "cpu" ]]; then
123-
:
123+
DOCKER_BINARY="docker"
124124
elif [[ ${TF_DOCKER_BUILD_TYPE} == "gpu" ]]; then
125+
DOCKER_BINARY="nvidia-docker"
126+
125127
FINAL_TAG="${FINAL_TAG}-gpu"
126128
if [[ ${ORIG_DOCKERFILE} == *"."* ]]; then
127129
# There is already a dot in the tag, use "-"
@@ -235,17 +237,18 @@ fi
235237
IMG="${USER}/tensorflow:${FINAL_TAG}"
236238
echo "Building docker image with image name and tag: ${IMG}"
237239

238-
docker build --no-cache -t "${IMG}" -f "${DOCKERFILE}" "${TMP_DIR}"
240+
"${DOCKER_BINARY}" build --no-cache -t "${IMG}" -f "${DOCKERFILE}" "${TMP_DIR}"
239241
if [[ $? == "0" ]]; then
240-
echo "docker build of ${IMG} succeeded"
242+
echo "${DOCKER_BINARY} build of ${IMG} succeeded"
241243
else
242-
die "FAIL: docker build of ${IMG} with Dockerfile ${DOCKERFILE} failed"
244+
die "FAIL: ${DOCKER_BINARY} build of ${IMG} with Dockerfile ${DOCKERFILE} "\
245+
"failed"
243246
fi
244247

245248

246249
# Make sure that there is no other containers of the same image running
247250
# TODO(cais): Move to an earlier place.
248-
if [[ ! -z $(docker ps | grep "${IMG}") ]]; then
251+
if [[ ! -z $("${DOCKER_BINARY}" ps | grep "${IMG}") ]]; then
249252
die "ERROR: It appears that there are docker containers of the image "\
250253
"${IMG} running. Please stop them before proceeding"
251254
fi
@@ -258,7 +261,7 @@ echo " (Log file is at: ${DOCKER_RUN_LOG}"
258261
echo ""
259262

260263
if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then
261-
docker run --rm -p ${CONTAINER_PORT}:${CONTAINER_PORT} \
264+
"${DOCKER_BINARY}" run --rm -p ${CONTAINER_PORT}:${CONTAINER_PORT} \
262265
-v ${TMP_DIR}/notebooks:/root/notebooks "${IMG}" \
263266
2>&1 > "${DOCKER_RUN_LOG}" &
264267

@@ -267,7 +270,7 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then
267270
while [[ -z ${CONTAINER_ID} ]]; do
268271
sleep 1
269272
echo "Polling for container ID..."
270-
CONTAINER_ID=$(docker ps | grep "${IMG}" | awk '{print $1}')
273+
CONTAINER_ID=$("${DOCKER_BINARY}" ps | grep "${IMG}" | awk '{print $1}')
271274
done
272275

273276
echo "ID of the running docker container: ${CONTAINER_ID}"
@@ -293,10 +296,10 @@ if [[ "${TF_DOCKER_BUILD_IS_DEVEL}" == "no" ]]; then
293296

294297
# Stop the running docker container
295298
sleep 1
296-
docker stop --time=0 ${CONTAINER_ID}
299+
"${DOCKER_BINARY}" stop --time=0 ${CONTAINER_ID}
297300

298301
else
299-
docker run --rm -p ${CONTAINER_PORT}:${CONTAINER_PORT} \
302+
"${DOCKER_BINARY}" run --rm -p ${CONTAINER_PORT}:${CONTAINER_PORT} \
300303
-v ${TMP_DIR}/notebooks:/root/notebooks "${IMG}" \
301304
bash -c \
302305
"cd /tensorflow; tensorflow/tools/ci_build/builds/test_tutorials.sh"
@@ -324,9 +327,9 @@ fi
324327
# Apply the final image name and tag
325328
FINAL_IMG="${FINAL_IMAGE_NAME}:${FINAL_TAG}"
326329

327-
DOCKER_VER=$(docker version | grep Version | head -1 | awk '{print $NF}')
330+
DOCKER_VER=$("${DOCKER_BINARY}" version | grep Version | head -1 | awk '{print $NF}')
328331
if [[ -z "${DOCKER_VER}" ]]; then
329-
die "ERROR: Failed to determine docker version"
332+
die "ERROR: Failed to determine ${DOCKER_BINARY} version"
330333
fi
331334
DOCKER_MAJOR_VER=$(echo "${DOCKER_VER}" | cut -d. -f 1)
332335
DOCKER_MINOR_VER=$(echo "${DOCKER_VER}" | cut -d. -f 2)
@@ -337,7 +340,7 @@ if [[ "${DOCKER_MAJOR_VER}" -le 1 ]] && \
337340
FORCE_TAG="--force"
338341
fi
339342

340-
docker tag ${FORCE_TAG} "${IMG}" "${FINAL_IMG}" || \
343+
"${DOCKER_BINARY}" tag ${FORCE_TAG} "${IMG}" "${FINAL_IMG}" || \
341344
die "Failed to tag intermediate docker image ${IMG} as ${FINAL_IMG}"
342345

343346
echo ""

0 commit comments

Comments
 (0)