Skip to content

Commit 27578aa

Browse files
fredrectensorflower-gardener
authored andcommitted
Update the Ubuntu CI Dockerfile
To be able to build recent versions of TFMOT. PiperOrigin-RevId: 415245844
1 parent 0b2c262 commit 27578aa

File tree

1 file changed

+28
-40
lines changed

1 file changed

+28
-40
lines changed

ci/kokoro/gcp_ubuntu/Dockerfile

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,40 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# An image for building prerequisites for testing TensorFlow Model Optimization
16-
# on ubuntu.
15+
# An image for building and testing TensorFlow Model Optimization on Ubuntu.
1716
#
18-
# TODO(b/185727356): generalize to different versions of TensorFlow to
19-
# run CI against.
20-
#
21-
# Build as follows:
22-
# docker build --tag={TAG} /path/to/directory/with/this/file
17+
# Usage, assuming that the current directory is the root of the GitHub repos:
2318
#
24-
# Run interactively as follows, where WORKDIR is the root directory
25-
# of the tensorflow model optimization Github repository.
19+
# Build:
20+
# docker build --tag={TAG} ci/kokoro/gcp_ubuntu/
2621
#
27-
# docker run -it --volume "${WORKDIR}:/usr/src/tfmot" {TAG}
22+
# Run interactively:
23+
# docker run -it --volume `pwd`:/tfmot --workdir /tfmot {TAG}
24+
25+
# TODO(b/185727356): generalize to different versions of TensorFlow to
26+
# run CI against.
27+
28+
# Latest Ubuntu LTS (Focal), at the moment.
29+
FROM ubuntu:20.04
30+
31+
ARG BAZEL_VERSION=4.2.2
32+
ARG TENSORFLOW_VERSION=2.7.0
2833

29-
FROM ubuntu:18.04
30-
WORKDIR /usr/src/tfmot
3134

3235
RUN apt-get update -y
3336

34-
# Install Python 3.
35-
#
36-
# Using Python 3.7 since 3.8 is not compatible with TensorFlow
37-
# versions <= 2.1.
38-
RUN apt-get install -y software-properties-common
39-
RUN add-apt-repository ppa:deadsnakes/ppa
40-
RUN apt-get install -y python3.7
41-
ENV PYTHON_BIN /usr/bin/python3.7
37+
# Install Python3 and set it as default
38+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
39+
python3 \
40+
python3-pip \
41+
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10
4242

4343
# Install Bazel.
44-
# https://docs.bazel.build/versions/master/install-ubuntu.html
45-
ARG BAZEL_VERSION=3.4.1
46-
RUN apt-get install -y unzip zip wget \
47-
&& wget "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION?}/bazel-${BAZEL_VERSION?}-installer-linux-x86_64.sh" \
48-
&& chmod +x "bazel-${BAZEL_VERSION?}-installer-linux-x86_64.sh" \
49-
&& "./bazel-${BAZEL_VERSION?}-installer-linux-x86_64.sh" --user \
50-
&& rm "bazel-${BAZEL_VERSION?}-installer-linux-x86_64.sh"
51-
ENV PATH "/root/bin:${PATH}"
52-
53-
# Install clang, which is required by bazel during building TFMOT.
54-
RUN apt-get install -y clang
55-
ENV CC clang
56-
57-
# Install pip.
58-
RUN apt-get install -y python3-pip
59-
# Upgrade pip3 to be able to detect additional TensorFlow versions.
60-
RUN pip3 install --upgrade pip
61-
62-
# Install latest TensorFlow 2.0.X.
63-
RUN pip3 install tensorflow==2.0.0
44+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y unzip zip wget \
45+
&& wget -O bazel-installer.sh "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION?}/bazel-${BAZEL_VERSION?}-installer-linux-x86_64.sh" \
46+
&& chmod +x "bazel-installer.sh" \
47+
&& "./bazel-installer.sh" \
48+
&& rm "bazel-installer.sh"
49+
50+
# Install TensorFlow
51+
RUN pip install "tensorflow==${TENSORFLOW_VERSION}"

0 commit comments

Comments
 (0)