cd /work
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
git checkout v2.3.0

patch -p1 <<"EOF"
diff --git a/tensorflow/stream_executor/cuda/cuda_blas.cc b/tensorflow/stream_executor/cuda/cuda_blas.cc
index f32c8b3..0fb5858 100644
--- a/tensorflow/stream_executor/cuda/cuda_blas.cc
+++ b/tensorflow/stream_executor/cuda/cuda_blas.cc
@@ -2277,7 +2277,7 @@ port::Status CUDABlas::DoBlasGemmBatchedInternal(

   cudaDataType_t data_type = CUDADataType<T>::type;

-#if CUDA_VERSION >= 9010
+#if 0 && CUDA_VERSION >= 9010
   int cc_major, cc_minor;
   if (stream->parent()->GetDeviceDescription().cuda_compute_capability(
           &cc_major, &cc_minor) &&
@@ -2449,7 +2449,7 @@ bool CUDABlas::DoBlasGemmStridedBatched(
     int lda, int64 stride_a, const DeviceMemory<Eigen::half> &b, int ldb,
     int64 stride_b, float beta, DeviceMemory<Eigen::half> *c, int ldc,
     int64 stride_c, int batch_count) {
-#if CUDA_VERSION >= 9010
+#if 0 && CUDA_VERSION >= 9010
   int cc_major, cc_minor;
   if (stream->parent()->GetDeviceDescription().cuda_compute_capability(
           &cc_major, &cc_minor) &&
diff --git a/tensorflow/stream_executor/lib/statusor_internals.h b/tensorflow/stream_executor/lib/statusor_internals.h
index d3a6026..431e088 100644
--- a/tensorflow/stream_executor/lib/statusor_internals.h
+++ b/tensorflow/stream_executor/lib/statusor_internals.h
@@ -163,6 +163,7 @@ class StatusOrData {
   }

   bool ok() const { return status_.ok(); }
+  bool ok() { return status_.ok(); }

  protected:
   // status_ will always be active after the constructor.
diff --git a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
index 271e941..7d37139 100644
--- a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
+++ b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch
@@ -1,3 +1,14 @@
+--- ./absl/time/internal/cctz/include/cctz/civil_time_detail.h 2020-08-06 01:33:56.005757145 +0200
++++ ./absl/time/internal/cctz/include/cctz/civil_time_detail.h 2020-08-06 01:33:35.460579387 +0200
+@@ -23,7 +23,7 @@
+ #include "absl/base/config.h"
+
+ // Disable constexpr support unless we are in C++14 mode.
+-#if __cpp_constexpr >= 201304 || (defined(_MSC_VER) && _MSC_VER >= 1910)
++#if (0 && __cpp_constexpr >= 201304) || (defined(_MSC_VER) && _MSC_VER >= 1910)
+ #define CONSTEXPR_D constexpr  // data
+ #define CONSTEXPR_F constexpr  // function
+ #define CONSTEXPR_M constexpr  // member
 --- ./absl/time/internal/cctz/BUILD.bazel      2019-09-23 13:20:52.000000000 -0700
 +++ ./absl/time/internal/cctz/BUILD.bazel.fixed        2019-09-23 13:20:48.000000000 -0700
 @@ -74,15 +74,6 @@
EOF

# set up env variables so that configure does not actually ask any questions
# skeleton from https://gist.github.com/PatWie/0c915d5be59a518f934392219ca65c3d
# actual numbers from compiling locally to be able to respond to interactive
# prompt, then (mostly) from .tf_configure.bazelrc

export PYTHON_BIN_PATH=/usr/bin/python3
export PYTHON_LIB_PATH="$($PYTHON_BIN_PATH -c 'import site; print(site.getsitepackages()[0])')"
export CUDA_TOOLKIT_PATH=/usr/local/cuda
export CUDNN_INSTALL_PATH=/usr/local/cuda-9.1
export NCCL_INSTALL_PATH=/usr/local/cuda-9.1

export TF_NEED_GCP=0
export TF_NEED_CUDA=1
export TF_CUDA_VERSION=9.1
export TF_CUDA_COMPUTE_CAPABILITIES=3.5
export TF_NEED_IGNITE=0
export TF_NEED_ROCM=0
export TF_NEED_HDFS=0
export TF_NEED_OPENCL=0
export TF_NEED_JEMALLOC=1
export TF_ENABLE_XLA=0
export TF_NEED_VERBS=0
export TF_CUDA_CLANG=0
export TF_CUDNN_VERSION=7
export TF_NEED_MKL=0
export TF_DOWNLOAD_MKL=0
export TF_NEED_AWS=0
export TF_NEED_MPI=1
export MPI_HOME=/usr/lib/mpich
export TF_NEED_GDR=0
export TF_NEED_S3=0
export TF_NEED_OPENCL_SYCL=0
export TF_SET_ANDROID_WORKSPACE=0
export TF_NEED_COMPUTECPP=0
export GCC_HOST_COMPILER_PATH=/usr/bin/gcc
export CC_OPT_FLAGS="-march=native"
export TF_NEED_KAFKA=0
export TF_NEED_TENSORRT=0
export TF_NCCL_VERSION=2

PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

./configure

# clean up env and PATH to use only data in the container
unset JAVA_HOME SDK_HOME JDK_HOME JAVA_ROOT JAVA_BINDIR
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

mkdir -p /work/bazel_cache $HOME/.cache
ln -sf /work/bazel_cache  $HOME/.cache/bazel

# local_cpu_resources is the number of parallel compiler processes to use
# a (late) build stage is very memory hungry and may run out of memory if
# using too many processes
bazel build  --local_cpu_resources=4 --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
./bazel-bin/tensorflow/tools/pip_package/build_pip_package /work/

rm $HOME/.cache/bazel

mkdir -p $PBS_O_WORKDIR/packages/
cp /work/tensorflow-2.3.0-cp35-cp35m-linux_x86_64.whl $PBS_O_WORKDIR/packages/
