From 6ba2ba639f13ece9fbb811bb9ff75e0cde9c3583 Mon Sep 17 00:00:00 2001 From: Chandra Devarakonda <chandrasekhard@google.com> Date: Tue, 12 Mar 2024 22:30:12 +0000 Subject: [PATCH] Add TPU configs --- .../test.import_tpu.sh | 19 ++++++ tensorflow_runtime_dockerfiles/tpu.Dockerfile | 62 +++++++++++++++++++ .../tpu.packages.txt | 5 ++ .../tpu.requirements.txt | 1 + 4 files changed, 87 insertions(+) create mode 100755 tensorflow_runtime_dockerfiles/test.import_tpu.sh create mode 100644 tensorflow_runtime_dockerfiles/tpu.Dockerfile create mode 100644 tensorflow_runtime_dockerfiles/tpu.packages.txt create mode 100644 tensorflow_runtime_dockerfiles/tpu.requirements.txt diff --git a/tensorflow_runtime_dockerfiles/test.import_tpu.sh b/tensorflow_runtime_dockerfiles/test.import_tpu.sh new file mode 100755 index 0000000..b73bd86 --- /dev/null +++ b/tensorflow_runtime_dockerfiles/test.import_tpu.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# Copyright 2018 The TensorFlow Authors. All Rights Reserved. +# +# 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. +# ============================================================================ + +set -euxo pipefail +python -c 'import tensorflow as tf' diff --git a/tensorflow_runtime_dockerfiles/tpu.Dockerfile b/tensorflow_runtime_dockerfiles/tpu.Dockerfile new file mode 100644 index 0000000..a69400d --- /dev/null +++ b/tensorflow_runtime_dockerfiles/tpu.Dockerfile @@ -0,0 +1,62 @@ +# Copyright 2019 The TensorFlow Authors. All Rights Reserved. +# +# 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. +# ============================================================================ + +FROM ubuntu:22.04 as base +ENV DEBIAN_FRONTEND=noninteractive +ENV LANG C.UTF-8 + +COPY setup.sources.sh /setup.sources.sh +COPY setup.packages.sh /setup.packages.sh +COPY cpu.packages.txt /cpu.packages.txt +RUN /setup.sources.sh +RUN /setup.packages.sh /cpu.packages.txt + + +ARG PYTHON_VERSION=python3.11 +ARG TENSORFLOW_PACKAGE=tf-nightly-tpu +COPY setup.python.sh /setup.python.sh +COPY cpu.requirements.txt /tpu.requirements.txt +RUN /setup.python.sh $PYTHON_VERSION /tpu.requirements.txt +RUN pip install --no-cache-dir ${TENSORFLOW_PACKAGE} -f https://storage.googleapis.com/libtpu-tf-releases/index.html +ENV NEXT_PLUGGABLE_DEVICE_USE_C_API=true +ENV TF_PLUGGABLE_DEVICE_LIBRARY_PATH="" # Initialize + +# Dynamically determine libtpu installation path +RUN python -c "import libtpu; import os; print(os.path.join(os.path.dirname(libtpu.__file__), 'libtpu.so'))" \ + | tee /out/.libtpu_path # Capture the output + +# Set the environment variable +ENV TF_PLUGGABLE_DEVICE_LIBRARY_PATH=$(cat /out/.libtpu_path) + +COPY bashrc /etc/bash.bashrc +RUN chmod a+rwx /etc/bash.bashrc + +FROM base as jupyter + +COPY jupyter.requirements.txt /jupyter.requirements.txt +COPY setup.jupyter.sh /setup.jupyter.sh +RUN python3 -m pip install --no-cache-dir -r /jupyter.requirements.txt -U +RUN /setup.jupyter.sh +COPY jupyter.readme.md /tf/tensorflow-tutorials/README.md + +WORKDIR /tf +EXPOSE 8888 + +CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root"] + +FROM base as test + +COPY test.import_tpu.sh /test.import_tpu.sh +RUN /test.import_tpu.sh diff --git a/tensorflow_runtime_dockerfiles/tpu.packages.txt b/tensorflow_runtime_dockerfiles/tpu.packages.txt new file mode 100644 index 0000000..cd1867a --- /dev/null +++ b/tensorflow_runtime_dockerfiles/tpu.packages.txt @@ -0,0 +1,5 @@ +build-essential +pkg-config +curl +software-properties-common +unzip diff --git a/tensorflow_runtime_dockerfiles/tpu.requirements.txt b/tensorflow_runtime_dockerfiles/tpu.requirements.txt new file mode 100644 index 0000000..2ae252f --- /dev/null +++ b/tensorflow_runtime_dockerfiles/tpu.requirements.txt @@ -0,0 +1 @@ +# nothing! -- GitLab