|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
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. |
17 | 16 | # |
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: |
23 | 18 | # |
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/ |
26 | 21 | # |
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 |
28 | 33 |
|
29 | | -FROM ubuntu:18.04 |
30 | | -WORKDIR /usr/src/tfmot |
31 | 34 |
|
32 | 35 | RUN apt-get update -y |
33 | 36 |
|
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 |
42 | 42 |
|
43 | 43 | # 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