Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
payalord committed Nov 1, 2022
0 parents commit af836c2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Tensorflow

Docker files ready to build tensorflow and it's addons from source files.

16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.9"
services:
tensorflow:
build:
context: ./tensorflow
dockerfile: Dockerfile
container_name: tensorflow
image: tensorflow:r2.11
tensorflow-addons:
build:
context: ./tensorflow-addons
dockerfile: Dockerfile
container_name: tensorflow-addons
image: tensorflow-addons:r0.18
depends_on:
- "tensorflow"
33 changes: 33 additions & 0 deletions tensorflow-addons/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG UBUNTU_VERSION=latest
FROM ubuntu:${UBUNTU_VERSION} AS tfa-build
RUN apt-get update
RUN apt-get install -y python3-dev python3-pip
RUN pip install -U pip numpy wheel packaging requests opt_einsum
RUN pip install -U keras_preprocessing --no-deps

RUN apt-get install -y apt-transport-https curl gnupg
RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel-archive-keyring.gpg
RUN mv bazel-archive-keyring.gpg /usr/share/keyrings
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
ARG BAZEL_VERSION=5.3.0
RUN apt-get update && apt-get install -y bazel-${BAZEL_VERSION}
RUN ln -s /usr/bin/bazel-${BAZEL_VERSION} /usr/bin/bazel

WORKDIR /
RUN apt-get -y install git rsync python-is-python3
RUN git clone https://github.com/tensorflow/addons.git
WORKDIR /addons
ARG TF_ADDONS_BRANCH=r0.18
RUN git checkout ${TF_ADDONS_BRANCH}
RUN python ./configure.py
RUN bazel build build_pip_pkg
RUN bazel-bin/build_pip_pkg artifacts

FROM ubuntu:${UBUNTU_VERSION} AS tfa-install
ARG DEBIAN_FRONTEND=noninteractive
COPY --from=tfa-build /addons/artifacts/*.whl /wheels/
RUN pip install /wheels/tensorflow_addons-*.whl

RUN python3 -c "import tensorflow_addons as tfa"

CMD ["python3"]
45 changes: 45 additions & 0 deletions tensorflow/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
ARG UBUNTU_VERSION=latest
FROM ubuntu:${UBUNTU_VERSION} AS tf-build
RUN apt-get update
RUN apt-get install -y python3-dev python3-pip
RUN pip install -U pip numpy wheel packaging requests opt_einsum
RUN pip install -U keras_preprocessing --no-deps

RUN apt-get install -y apt-transport-https curl gnupg
RUN curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel-archive-keyring.gpg
RUN mv bazel-archive-keyring.gpg /usr/share/keyrings
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
ARG BAZEL_VERSION=5.3.0
RUN apt-get update && apt-get install -y bazel-${BAZEL_VERSION}
RUN ln -s /usr/bin/bazel-${BAZEL_VERSION} /usr/bin/bazel

WORKDIR /
RUN apt-get -y install git

RUN git clone https://github.com/tensorflow/tensorflow.git
WORKDIR /tensorflow
ARG TENSORFLOW_BRANCH=r2.11
RUN git checkout ${TENSORFLOW_BRANCH}

# CPU support configuration
RUN ./configure

# CPU only support
RUN bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

# GPU support
#RUN bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

# Build pip whl package
RUN ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

FROM ubuntu:${UBUNTU_VERSION} AS tf-install
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y python3 python3-pip
COPY --from=tf-build /tmp/tensorflow_pkg/*.whl wheels/
RUN pip install /wheels/tensorflow-*.whl

RUN python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

CMD ["python3"]

0 comments on commit af836c2

Please sign in to comment.