blob: a6cd44ced1d546846f274ef79aad75bcf950fd03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
FROM tensorflow/tensorflow:latest-devel
LABEL maintainer="Clayne Robison<clayne.b.robison@intel.com>"
# These arguments are parameterized. Use --build-args to override.
ARG TF_BRANCH=r1.8
ARG WHL_DIR=/whl
RUN apt-get update && apt-get install -y --no-install-recommends \
golang \
vim \
emacs \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN pip --no-cache-dir install --upgrade \
pip setuptools
RUN pip --no-cache-dir install wheel
# Download and build TensorFlow.
WORKDIR /
RUN rm -rf tensorflow && \
git clone https://github.com/tensorflow/tensorflow.git && \
cd tensorflow && \
git checkout ${TF_BRANCH}
WORKDIR /tensorflow
# Configure the build for CPU with MKL by accepting default build options and
# setting library locations
ENV CI_BUILD_PYTHON=python \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
PYTHON_BIN_PATH=/usr/bin/python \
PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages \
CC_OPT_FLAGS='-march=native' \
TF_NEED_JEMALLOC=0 \
TF_NEED_GCP=1 \
TF_NEED_CUDA=0 \
TF_NEED_HDFS=0 \
TF_NEED_S3=1 \
TF_NEED_OPENCL=0 \
TF_NEED_GDR=0 \
TF_ENABLE_XLA=0 \
TF_NEED_VERBS=0 \
TF_NEED_MPI=0
RUN ./configure
# Build and Install TensorFlow.
# The 'mkl' option builds with Intel(R) Math Kernel Library (MKL), which detects
# the platform it is currently running on and takes appropriately optimized
# paths. The -march=native option is for code that is not in MKL, and assumes
# this container will be run on the same architecture on which it is built.
RUN LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
bazel build --config=mkl \
--config="opt" \
--copt="-march=broadwell" \
--copt="-O3" \
//tensorflow/tools/pip_package:build_pip_package && \
mkdir ${WHL_DIR} && \
bazel-bin/tensorflow/tools/pip_package/build_pip_package ${WHL_DIR}
# Clean up Bazel cache when done, but leave the whl.
# This will upgrade the default Tensorflow version with the Intel MKL version
RUN pip --no-cache-dir install --upgrade ${WHL_DIR}/tensorflow-*.whl && \
rm -rf /root/.cache
WORKDIR /root
#add welcome message with instructions
RUN echo '[ ! -z "$TERM" -a -r /etc/motd ] && cat /etc/issue && cat /etc/motd' \
>> /etc/bash.bashrc \
; echo "\
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n\
| \n\
| Docker container running Ubuntu \n\
| with TensorFlow ${TF_BRANCH} optimized for CPU \n\
| with Intel(R) MKL \n\
| \n\
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n\
\n "\
> /etc/motd
|