Skip to content

Commit

Permalink
make tpu tensorflow build conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
djherbis committed May 16, 2022
1 parent b22de75 commit 2105bc6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
18 changes: 17 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ pipeline {
'''
}
}
stage('tensorflow TPU') {
options {
timeout(time: 180, unit: 'MINUTES')
}
steps {
sh '''#!/bin/bash
set -exo pipefail
source tpu/config.txt
cd packages/
./build_package --base-image gcr.io/kaggle-images/python:${BASE_IMAGE_TAG} \
--package tpu-tensorflow \
--version $TENSORFLOW_VERSION \
--push
'''
}
}
}
}
stage('Build/Test/Diff') {
Expand Down Expand Up @@ -155,7 +171,7 @@ pipeline {
stages {
stage('Build Tensorflow TPU Image') {
options {
timeout(time: 120, unit: 'MINUTES')
timeout(time: 20, unit: 'MINUTES')
}
steps {
sh '''#!/bin/bash
Expand Down
2 changes: 2 additions & 0 deletions packages/build_package
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ fi

# Keep only `tf2-gpu.2-6:m80` in `gcr.io/deeplearning-platform-release/tf2-gpu.2-6:m80`
TAG=${BASE_IMAGE/gcr.io\/deeplearning-platform-release\//}
# Keep only `python:v108` in `gcr.io/kaggle-images/python:v108`
TAG=${TAG/gcr.io\/kaggle-images\//}
# Replace the `:` in `tf2-gpu.2-6:m80` by `-`
TAG=${TAG/:/-}
# Append the package version
Expand Down
6 changes: 3 additions & 3 deletions packages/tpu-tensorflow.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE_TAG
ARG BASE_IMAGE

FROM gcr.io/kaggle-images/python:${BASE_IMAGE_TAG} AS builder
FROM ${BASE_IMAGE} AS builder

ARG PACKAGE_VERSION

Expand All @@ -14,7 +14,7 @@ RUN cd /usr/local/src && \
RUN cd /usr/local/src && \
git clone https://github.com/tensorflow/tensorflow && \
cd tensorflow && \
git checkout tags/v${TENSORFLOW_VERSION} && \
git checkout tags/v${PACKAGE_VERSION} && \
# TODO(rosbo): Is it really needed?
pip install keras_applications --no-deps && \
pip install keras_preprocessing --no-deps
Expand Down
4 changes: 2 additions & 2 deletions tpu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ARG BASE_IMAGE_TAG
ARG LIBTPU_IMAGE_TAG
ARG TENSORFLOW_WHL_IMAGE_TAG
ARG TENSORFLOW_VERSION

FROM gcr.io/cloud-tpu-v2-images/libtpu:${LIBTPU_IMAGE_TAG} as libtpu
FROM gcr.io/kaggle-images/python-tpu-tensorflow-whl:${TENSORFLOW_WHL_IMAGE_TAG} AS tensorflow_whl
FROM gcr.io/kaggle-images/python-tpu-tensorflow-whl:python-${BASE_IMAGE_TAG}-${TENSORFLOW_VERSION} AS tensorflow_whl
FROM gcr.io/kaggle-images/python:${BASE_IMAGE_TAG}

ENV ISTPUVM=1
Expand Down
6 changes: 0 additions & 6 deletions tpu/build
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ EOF
}

CACHE_FLAG='--no-cache'
TENSORFLOW_DOCKERFILE='tensorflow.Dockerfile'
TENSORFLOW_IMAGE_TAG='kaggle/python-tpuvm-tensorflow-build'
DOCKERFILE='Dockerfile'
IMAGE_TAG='kaggle/python-tpuvm-build'
BUILD_ARGS=''
Expand Down Expand Up @@ -49,15 +47,11 @@ for l in `cat ${SRCDIR}/config.txt`; do
done

readonly CACHE_FLAG
readonly TENSORFLOW_DOCKERFILE
readonly TENSORFLOW_IMAGE_TAG
readonly DOCKERFILE
readonly IMAGE_TAG
readonly BUILD_ARGS

TENSORFLOW_DOCKERFILE_PATH="$SRCDIR/$TENSORFLOW_DOCKERFILE"
DOCKERFILE_PATH="$SRCDIR/$DOCKERFILE"

set -x
docker build --rm --pull $CACHE_FLAG -t "$TENSORFLOW_IMAGE_TAG" -f "$TENSORFLOW_DOCKERFILE_PATH" $BUILD_ARGS .
docker build --rm --pull $CACHE_FLAG -t "$IMAGE_TAG" -f "$DOCKERFILE_PATH" $BUILD_ARGS .
2 changes: 1 addition & 1 deletion tpu/config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BASE_IMAGE_TAG=v108
LIBTPU_IMAGE_TAG=libtpu_1.1.0_RC00
TENSORFLOW_WHL_IMAGE_TAG=local
TENSORFLOW_VERSION=2.8.0

0 comments on commit 2105bc6

Please sign in to comment.