-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Build target: lablup/common-bazel-alpine | ||
FROM lablup/kernel-python3:latest | ||
|
||
RUN apk add --no-cache --virtual=.build-deps \ | ||
bash \ | ||
cmake \ | ||
curl \ | ||
freetype-dev \ | ||
g++ \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
linux-headers \ | ||
make \ | ||
musl-dev \ | ||
openblas-dev \ | ||
openjdk8 \ | ||
patch \ | ||
perl \ | ||
rsync \ | ||
sed \ | ||
swig \ | ||
git \ | ||
zip | ||
|
||
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk | ||
ENV BAZEL_VERSION 0.5.2 | ||
|
||
RUN : install Bazel to build TensorFlow \ | ||
&& curl -SLO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip \ | ||
&& mkdir bazel-${BAZEL_VERSION} \ | ||
&& unzip -qd bazel-${BAZEL_VERSION} bazel-${BAZEL_VERSION}-dist.zip \ | ||
&& cd bazel-${BAZEL_VERSION} \ | ||
&& : add -fpermissive compiler option to avoid compilation failure \ | ||
&& sed -i -e '/"-std=c++0x"/{h;s//"-fpermissive"/;x;G}' tools/cpp/cc_configure.bzl \ | ||
&& : add '#include <sys/stat.h>' to avoid mode_t type error \ | ||
&& sed -i -e '/#endif \/\/ COMPILER_MSVC/{h;s//#else/;G;s//#include <sys\/stat.h>/;G;}' third_party/ijar/common.h \ | ||
&& bash compile.sh \ | ||
&& cp -p output/bazel /usr/local/bin/ | ||
|
||
RUN ls -l /usr/local/bin/bazel* | ||
|
||
# ft=dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
ARG TF_VERSION | ||
|
||
FROM lablup/common-bazel-alpine as bazel-binary | ||
|
||
|
||
# Build target: lablup/common-python3-tensorflow-cpu | ||
# ref: https://github.com/tatsushid/docker-alpine-py3-tensorflow-jupyter/blob/master/Dockerfile | ||
FROM lablup/kernel-python3:latest | ||
|
||
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk | ||
COPY --from=bazel-binary /usr/local/bin/bazel /usr/local/bin/ | ||
|
||
RUN apk add --no-cache --virtual=.build-deps \ | ||
bash \ | ||
imagemagick \ | ||
graphviz \ | ||
cmake \ | ||
curl \ | ||
freetype-dev \ | ||
g++ \ | ||
libjpeg-turbo-dev \ | ||
libpng-dev \ | ||
linux-headers \ | ||
make \ | ||
musl-dev \ | ||
openblas-dev \ | ||
openjdk8 \ | ||
patch \ | ||
perl \ | ||
rsync \ | ||
sed \ | ||
swig \ | ||
git \ | ||
zip | ||
RUN : check bazel is runnable \ | ||
&& bazel version | ||
RUN : prepare for building TensorFlow \ | ||
&& : install wheel python module \ | ||
&& cd /tmp \ | ||
&& pip3 install --no-cache-dir wheel | ||
|
||
# Limit the system resource used during compilation | ||
ENV LOCAL_RESOURCES 2048,.5,1.0 | ||
|
||
# The TensorFlow version | ||
ENV TF_VERSION ${TF_VERSION:-1.3.0} | ||
|
||
RUN : build TensorFlow pip package \ | ||
&& cd /tmp \ | ||
&& curl -SL https://github.com/tensorflow/tensorflow/archive/v${TF_VERSION}.tar.gz \ | ||
| tar xzf - \ | ||
&& cd tensorflow-${TF_VERSION} \ | ||
# && : add python symlink to avoid python detection error in configure \ | ||
# && $(cd /usr/local/bin && ln -s python3 python) \ | ||
&& : musl-libc does not have "secure_getenv" function \ | ||
&& sed -i -e '/JEMALLOC_HAVE_SECURE_GETENV/d' third_party/jemalloc.BUILD \ | ||
&& PYTHON_BIN_PATH=/usr/local/bin/python \ | ||
PYTHON_LIB_PATH=/usr/local/lib/python3.6/site-packages \ | ||
CC_OPT_FLAGS="-march=x86-64 --copt=-mavx --copt=-msse4.1 --copt=-msse4.2" \ | ||
TF_NEED_MKL=0 \ | ||
TF_NEED_JEMALLOC=1 \ | ||
TF_NEED_GCP=0 \ | ||
TF_NEED_HDFS=0 \ | ||
TF_ENABLE_XLA=0 \ | ||
TF_NEED_VERBS=0 \ | ||
TF_NEED_OPENCL=0 \ | ||
TF_NEED_CUDA=0 \ | ||
TF_NEED_MPI=0 \ | ||
bash configure \ | ||
&& bazel build -c opt --local_resources ${LOCAL_RESOURCES} //tensorflow/tools/pip_package:build_pip_package \ | ||
&& ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg | ||
|
||
RUN ls -l /tmp/tensorflow_pkg | ||
|
||
# vim: ft=dockerfile |