Skip to content

Commit

Permalink
Dockerfiles to use for ngraph-packaging (#338)
Browse files Browse the repository at this point in the history
* First attempt at a Dockerfile that works with ngraph-packaging without triggering the dreaded pip bug.  The new Dockerfile added here seems to work.

* Added a Dockerfile which allows ngraph-packaging to work with gcc 4.8 builds.  This Dockerfile successfully built the ngraph_config wheel.
  • Loading branch information
crlishka committed Nov 30, 2018
1 parent 9a32f4b commit 2c5fb25
Show file tree
Hide file tree
Showing 2 changed files with 176 additions and 0 deletions.
@@ -0,0 +1,97 @@
# ==============================================================================
# Copyright 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# Environment to build and unit-test ngraph-tensorflow-bridge

FROM ubuntu:16.04

# Default python environment is python 3, thus python3-pip and virtualenv
# python3-dev is needed for TensorFlow build
# git is needed to clone tensorflow repository
# unzip and wget are needed for installing bazel
# sudo is required for installing the TF wheel into /usr/local/...
# zlib1g, zlib1g-dev and bash-completion are required by bazel install
# zip and golang-go are needed to run TensorFlow tests
# curl and locate are needed by Tensorflow's configure command
# clang-format-3.9 is needed for code-style checks
RUN apt-get update && apt-get install -y \
python3-pip virtualenv \
python3-dev \
git \
unzip wget \
sudo \
zlib1g zlib1g-dev bash-completion \
build-essential cmake \
libtinfo-dev \
zip golang-go \
locate curl \
clang-format-3.9

# Install gcc 4.8 and configure it to be the preferred gcc XXXXX

RUN which gcc && gcc --version || true
RUN which c++ && c++ --version || true

RUN apt-get install -y gcc-4.8 g++-4.8

RUN which gcc && gcc --version || true
RUN which c++ && c++ --version || true

# Setup gcc-4.8 compiler per https://github.com/NervanaSystems/ngraph/blob/master/INSTALL
# If you are using gcc-4.8, it may be necessary to add symlinksfrom `gcc` to
# `gcc-4.8`, and from `g++` to `g++-4.8`, in your PATH, even if you have
# specify CMAKE_C_COMPILER and CMAKE_CXX_COMPILER when building. (You should
# NOT supply the `-DNGRAPH_USE_PREBUILT_LLVM` flag in this case, because the
# prebuilt tarball supplied on llvm.org is not compatible with a gcc-4.8
# based build.)
RUN ln -f -s /usr/bin/gcc-4.8 /usr/bin/gcc || true
RUN ln -f -s /usr/bin/g++-4.8 /usr/bin/g++ || true
RUN which gcc && gcc --version || true
RUN which c++ && c++ --version || true

# The "locate" command uses a prepopulated index. If this index is not built,
# then "locate" will find absolutely nothing. In Tensorflow's configure,
# this manifests itself as a silent failure of the configure script to run to
# completion. Therefore, updatedb MUST BE RUN to provide an index for "locate".
RUN updatedb

# The pip-upgrade for pip, setuptools, and virtualenv is to avoid a nasty
# bug in setuptools: "_NamespacePath object has no attribute sort"
# yapf and futures are needed for code-format checks (ngraph-tf PR#211)
RUN pip3 install --upgrade pip setuptools virtualenv
RUN pip3 install yapf==0.24.0
RUN pip3 install futures

# We include pytest so the Docker image can be used for daily validation
RUN pip3 install --upgrade pytest

# FROM NG-TF:
# We need to be careful to run apt-get update in any RUN where apt-get install
# might be run. This is needed due to docker layer limitations.
# RUN apt-get update && ./initial-setup-once-per-machine.ubuntu-16.04.sh
#
# REPLACED BY:
RUN apt-get update && apt-get install -y openjdk-8-jdk
#
# This bazel version works with current TF
RUN wget --no-verbose -c https://github.com/bazelbuild/bazel/releases/download/0.16.0/bazel_0.16.0-linux-x86_64.deb
RUN dpkg -i bazel_0.16.0-linux-x86_64.deb || true

# Copy in the run-as-user.sh script
# This will allow the builds, which are done in a mounted directory, to
# be run as the user who runs "docker run". This then allows the mounted
# directory to be properly deleted by the user later (e.g. by jenkins).
WORKDIR /home
@@ -0,0 +1,79 @@
# ==============================================================================
# Copyright 2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# Environment to build and unit-test ngraph-tensorflow-bridge

FROM ubuntu:16.04

# Default python environment is python 3, thus python3-pip and virtualenv
# python3-dev is needed for TensorFlow build
# git is needed to clone tensorflow repository
# unzip and wget are needed for installing bazel
# sudo is required for installing the TF wheel into /usr/local/...
# zlib1g, zlib1g-dev and bash-completion are required by bazel install
# zip and golang-go are needed to run TensorFlow tests
# curl and locate are needed by Tensorflow's configure command
# clang-format-3.9 is needed for code-style checks
RUN apt-get update && apt-get install -y \
python3-pip virtualenv \
python3-dev \
git \
unzip wget \
sudo \
zlib1g zlib1g-dev bash-completion \
build-essential cmake \
libtinfo-dev \
zip golang-go \
locate curl \
clang-format-3.9

# Report which gcc and g++ versions are present
RUN which gcc && gcc --version || true
RUN which c++ && c++ --version || true

# The "locate" command uses a prepopulated index. If this index is not built,
# then "locate" will find absolutely nothing. In Tensorflow's configure,
# this manifests itself as a silent failure of the configure script to run to
# completion. Therefore, updatedb MUST BE RUN to provide an index for "locate".
RUN updatedb

# The pip-upgrade for pip, setuptools, and virtualenv is to avoid a nasty
# bug in setuptools: "_NamespacePath object has no attribute sort"
# yapf and futures are needed for code-format checks (ngraph-tf PR#211)
RUN pip3 install --upgrade pip setuptools virtualenv
RUN pip3 install yapf==0.24.0
RUN pip3 install futures

# We include pytest so the Docker image can be used for daily validation
RUN pip3 install --upgrade pytest

# FROM NG-TF:
# We need to be careful to run apt-get update in any RUN where apt-get install
# might be run. This is needed due to docker layer limitations.
# RUN apt-get update && ./initial-setup-once-per-machine.ubuntu-16.04.sh
#
# REPLACED BY:
RUN apt-get update && apt-get install -y openjdk-8-jdk
#
# This bazel version works with current TF
RUN wget --no-verbose -c https://github.com/bazelbuild/bazel/releases/download/0.16.0/bazel_0.16.0-linux-x86_64.deb
RUN dpkg -i bazel_0.16.0-linux-x86_64.deb || true

# Copy in the run-as-user.sh script
# This will allow the builds, which are done in a mounted directory, to
# be run as the user who runs "docker run". This then allows the mounted
# directory to be properly deleted by the user later (e.g. by jenkins).
WORKDIR /home

0 comments on commit 2c5fb25

Please sign in to comment.