From 32e457892f92e9f38fba1d99ff865327d366a647 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 16 Oct 2021 17:37:02 -0700 Subject: [PATCH 1/8] Linux dev container Signed-off-by: Ryan Nett --- dev-containers/linux/Dockerfile | 49 ++++++++++++++++++++++++++++ dev-containers/linux/entrypoint.sh | 30 +++++++++++++++++ dev-containers/linux/install_cuda.sh | 44 +++++++++++++++++++++++++ dev-containers/linux/scl_enable.sh | 20 ++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 dev-containers/linux/Dockerfile create mode 100644 dev-containers/linux/entrypoint.sh create mode 100644 dev-containers/linux/install_cuda.sh create mode 100644 dev-containers/linux/scl_enable.sh diff --git a/dev-containers/linux/Dockerfile b/dev-containers/linux/Dockerfile new file mode 100644 index 00000000000..80cfc6f93f4 --- /dev/null +++ b/dev-containers/linux/Dockerfile @@ -0,0 +1,49 @@ +FROM centos:7 + +ENV GLIBC "glibc glibc-common glibc-devel glibc-headers" +RUN yum --disablerepo updates -y install $GLIBC +RUN yum -x "$GLIBC" -y update && yum -x "$GLIBC" -y install centos-release-scl-rh && yum -x "$GLIBC" -y install \ + scl-utils \ + epel-release \ + java-1.8.0-openjdk-devel \ + devtoolset-7 \ + unzip \ + which \ + rh-git218 \ + patch \ + perl-Data-Dumper \ + python36-devel && yum -x "$GLIBC" -y install \ + python36-numpy \ + python36-pip \ + python36-six + +RUN echo "Downloading Maven" && \ + curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz && \ + tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ && \ + ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn + +RUN echo "Downloading Bazel" && \ + curl -L https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel-3.7.2-installer-linux-x86_64.sh -o bazel.sh --retry 10 && \ + bash bazel.sh + +ARG GPU=false + +ADD install_cuda.sh /install_cuda.sh +RUN chmod +x /install_cuda.sh +RUN /install_cuda.sh + +ENV JAVA_HOME /usr/lib/jvm/java-1.8.0 + +ADD scl_enable.sh /scl_enable.sh + +ADD entrypoint.sh /entrypoint +ENTRYPOINT [ "/entrypoint" ] + +ENV CI=true + +VOLUME /root/.m2 +VOLUME /root/.cache/bazel + +ENV BASH_ENV=/scl_enable.sh \ + ENV=/scl_enable.sh \ + PROMPT_COMMAND=". /scl_enable.sh" diff --git a/dev-containers/linux/entrypoint.sh b/dev-containers/linux/entrypoint.sh new file mode 100644 index 00000000000..17ee3c83d79 --- /dev/null +++ b/dev-containers/linux/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# + + + + +git --version +gcc --version +mvn -version +bazel version + +set -eu +cmd="$1"; shift +exec $cmd "$@" \ No newline at end of file diff --git a/dev-containers/linux/install_cuda.sh b/dev-containers/linux/install_cuda.sh new file mode 100644 index 00000000000..399747e2fd8 --- /dev/null +++ b/dev-containers/linux/install_cuda.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# + + + + + +echo "JAVA home is $(dirname $(dirname $(readlink $(readlink $(which javac)))))" + +if [ "$GPU" = "true" ]; then + echo Installing CUDA + curl -L https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda-repo-rhel7-11-2-local-11.2.2_460.32.03-1.x86_64.rpm -o $HOME/cuda.rpm + curl -L https://developer.download.nvidia.com/compute/redist/cudnn/v8.1.1/cudnn-11.2-linux-x64-v8.1.1.33.tgz -o $HOME/cudnn.tgz + curl -L https://developer.download.nvidia.com/compute/redist/nccl/v2.8/nccl_2.8.4-1+cuda11.2_x86_64.txz -o $HOME/nccl.txz + rpm -i $HOME/cuda.rpm + pushd /var/cuda-repo-rhel7-11-2-local/; rpm -i --nodeps cuda*.rpm libc*.rpm libn*.rpm; rm *.rpm; popd + ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/libcuda.so + ln -sf /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/libnvidia-ml.so + tar hxvf $HOME/cudnn.tgz -C /usr/local/ + tar hxvf $HOME/nccl.txz --strip-components=1 -C /usr/local/cuda/ + mv /usr/local/cuda/lib/* /usr/local/cuda/lib64/ + echo Removing downloaded archives and unused libraries to avoid running out of disk space + rm -f $HOME/*.rpm $HOME/*.tgz $HOME/*.txz $HOME/*.tar.* + rm -f $(find /usr/local/cuda/ -name '*.a' -and -not -name libcudart_static.a -and -not -name libcudadevrt.a) + rm -rf /usr/local/cuda/doc* /usr/local/cuda/libnvvp* /usr/local/cuda/nsight* /usr/local/cuda/samples* +else + echo "Skipping CUDA install" +fi \ No newline at end of file diff --git a/dev-containers/linux/scl_enable.sh b/dev-containers/linux/scl_enable.sh new file mode 100644 index 00000000000..df6a7b5f0f0 --- /dev/null +++ b/dev-containers/linux/scl_enable.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# +unset BASH_ENV PROMPT_COMMAND ENV +source scl_source enable devtoolset-7 rh-git218 \ No newline at end of file From 18b691b22eed693c3a425f4419b4dc1cfd4b9a4a Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 16 Oct 2021 17:37:13 -0700 Subject: [PATCH 2/8] WIP Windows dev container Signed-off-by: Ryan Nett --- dev-containers/windows/Dockerfile | 172 ++++++++++++++++++++++++ dev-containers/windows/entrypoint.bat | 17 +++ dev-containers/windows/install_cuda.bat | 9 ++ 3 files changed, 198 insertions(+) create mode 100644 dev-containers/windows/Dockerfile create mode 100644 dev-containers/windows/entrypoint.bat create mode 100644 dev-containers/windows/install_cuda.bat diff --git a/dev-containers/windows/Dockerfile b/dev-containers/windows/Dockerfile new file mode 100644 index 00000000000..e73ad4bc363 --- /dev/null +++ b/dev-containers/windows/Dockerfile @@ -0,0 +1,172 @@ +FROM mcr.microsoft.com/windows/servercore:ltsc2019 + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# Install MSYS2 + +RUN echo "Downloading MSYS2" ; \ + Invoke-WebRequest -UserAgent 'DockerCI' -outfile 7zsetup.exe http://www.7-zip.org/a/7z1604-x64.exe ; \ + Invoke-WebRequest -UserAgent 'DockerCI' -outfile msys2-x86_64-latest.tar.xz http://repo.msys2.org/distrib/msys2-x86_64-latest.tar.xz + + +RUN echo "Extracting MSYS2" ; \ + Start-Process .\7zsetup -ArgumentList '/S /D=c:/7zip' -Wait ; \ + C:\7zip\7z e msys2-x86_64-latest.tar.xz -Wait ; \ + C:\7zip\7z x msys2-x86_64-latest.tar -o"C:\\" ; \ + cmd /S /C "del /q *" + +RUN New-Item C:/temp -ItemType Directory; \ + New-Item C:/data -ItemType Directory; \ + New-Item C:/home -ItemType Directory; +WORKDIR C:/temp + +## Install Python + +ENV PYTHON_VERSION 3.7.9 +ENV PYTHON_RELEASE 3.7.9 + +RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \ + Write-Host ('Downloading {0} ...' -f $url); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ + \ + Write-Host 'Installing ...'; \ +# https://docs.python.org/3.7/using/windows.html#installing-without-ui + Start-Process python.exe -Wait \ + -ArgumentList @( \ + '/quiet', \ + 'InstallAllUsers=1', \ + 'TargetDir=C:\Python37', \ + 'PrependPath=1', \ + 'Shortcuts=0', \ + 'Include_doc=0', \ + 'Include_pip=0', \ + 'Include_test=0' \ + ); \ + \ +#the installer updated PATH, so we should refresh our local value + $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ + \ + Write-Host 'Verifying install ...'; \ + Write-Host ' python --version'; python --version; \ + \ + Write-Host 'Removing ...'; \ + Remove-Item python.exe -Force; \ + \ + Write-Host 'Complete.' + +# And pip + +# https://github.com/pypa/get-pip +ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/d59197a3c169cef378a22428a3fa99d33e080a5d/get-pip.py +ENV PYTHON_GET_PIP_SHA256 421ac1d44c0cf9730a088e337867d974b91bdce4ea2636099275071878cc189e + +RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \ + Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \ + if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + \ + Write-Host ('Installing pip ...'); \ + python get-pip.py \ + --disable-pip-version-check \ + --no-cache-dir \ + ; \ + Remove-Item get-pip.py -Force; \ + \ + Write-Host 'Verifying pip install ...'; \ + pip --version; \ + \ + Write-Host 'Complete.' + +WORKDIR C:/home + +RUN Remove-Item C:\temp + +## Install Java + +ENV JAVA_HOME C:\\openjdk-8 +RUN $newPath = ('{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH); \ + Write-Host ('Updating PATH: {0}' -f $newPath); \ + setx /M PATH $newPath; \ + Write-Host 'Complete.' + +# https://adoptopenjdk.net/upstream.html +# > +# > What are these binaries? +# > +# > These binaries are built by Red Hat on their infrastructure on behalf of the OpenJDK jdk8u and jdk11u projects. The binaries are created from the unmodified source code at OpenJDK. Although no formal support agreement is provided, please report any bugs you may find to https://bugs.java.com/. +# > +ENV JAVA_VERSION 8u302 +ENV JAVA_URL https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u302-b08/OpenJDK8U-jdk_x64_windows_8u302b08.zip +# https://github.com/docker-library/openjdk/issues/320#issuecomment-494050246 +# > +# > I am the OpenJDK 8 and 11 Updates OpenJDK project lead. +# > ... +# > While it is true that the OpenJDK Governing Board has not sanctioned those releases, they (or rather we, since I am a member) didn't sanction Oracle's OpenJDK releases either. As far as I am aware, the lead of an OpenJDK project is entitled to release binary builds, and there is clearly a need for them. +# > + +RUN Write-Host ('Downloading {0} ...' -f $env:JAVA_URL); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -Uri $env:JAVA_URL -OutFile 'openjdk.zip'; \ +# TODO signature? checksum? + \ + Write-Host 'Expanding ...'; \ + New-Item -ItemType Directory -Path C:\temp | Out-Null; \ + Expand-Archive openjdk.zip -DestinationPath C:\temp; \ + Move-Item -Path C:\temp\* -Destination $env:JAVA_HOME; \ + Remove-Item C:\temp; \ + \ + Write-Host 'Removing ...'; \ + Remove-Item openjdk.zip -Force; \ + \ + Write-Host 'Verifying install ...'; \ + Write-Host ' java -version'; java -version; \ + \ + Write-Host 'Complete.' + +SHELL ["cmd", "/S", "/C"] + +RUN echo "Installing VS Build Tools" && \ + curl -SL --output vs_buildtools.exe https://aka.ms/vs/16/release/vs_buildtools.exe \ + && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache modify \ + --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools" \ + --add Microsoft.VisualStudio.Workload.AzureBuildTools \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 \ + --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 \ + --remove Microsoft.VisualStudio.Component.Windows81SDK \ + || IF "%ERRORLEVEL%"=="3010" EXIT 0) \ + && del /q vs_buildtools.exe + +RUN setx PATH "C:\msys64\usr\bin;%PATH%" + +RUN echo "Downloading Maven" && \ + curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o apache-maven-3.6.3-bin.tar.gz && \ + tar xzf apache-maven-3.6.3-bin.tar.gz && \ + mv apache-maven-3.6.3 /c/. + +RUN setx PATH "%PATH%;C:\apache-maven-3.6.3\bin" + +RUN python -m pip install numpy six + +RUN echo Downloading Bazel && \ + mkdir C:\bazel && \ + curl.exe -L https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel-3.7.2-windows-x86_64.exe -o C:/bazel/bazel.exe --retry 10 + +ARG GPU=false + +ADD install_cuda.bat /install_cuda.bat +RUN /install_cuda.bat + +ADD entrypoint.bat /entrypoint.bat +ENTRYPOINT [ "/entrypoint.bat" ] + +ENV CI=true + +RUN pwd + +VOLUME "C:\temp\.m2" diff --git a/dev-containers/windows/entrypoint.bat b/dev-containers/windows/entrypoint.bat new file mode 100644 index 00000000000..3ad33833af1 --- /dev/null +++ b/dev-containers/windows/entrypoint.bat @@ -0,0 +1,17 @@ +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 +set "CUDA_PATH=%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v11.2" +set "CUDA_PATH_V11_2=%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v11.2" +set "PATH=C:\msys64\usr\bin;C:\bazel;C:\Program Files\Git\bin;%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin;%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libnvvp;%PATH%" +echo Shorten work paths to prevent Bazel from reaching MAX_PATH limit +set "TEST_TMPDIR=C:\tmp" +set "TMPDIR=C:\tmp" +set "TEMP=C:\tmp" +set "TMP=C:\tmp" +mkdir C:\tmp +bash --version +@REM git --version +@REM cl +echo %JAVA_HOME% +call mvn -version +bazel version +call %* \ No newline at end of file diff --git a/dev-containers/windows/install_cuda.bat b/dev-containers/windows/install_cuda.bat new file mode 100644 index 00000000000..8a498e78fdd --- /dev/null +++ b/dev-containers/windows/install_cuda.bat @@ -0,0 +1,9 @@ +if "%GPU%" == "true" ( + echo Installing CUDA + curl.exe -L https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_461.33_win10.exe -o cuda.exe + curl.exe -L https://developer.download.nvidia.com/compute/redist/cudnn/v8.1.1/cudnn-11.2-windows-x64-v8.1.1.33.zip -o cudnn.zip + cuda.exe -s + mkdir cuda + unzip.exe cudnn.zip + cp.exe -a cuda/include cuda/lib cuda/bin "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/" +) \ No newline at end of file From 1612b6f40ecc770d7c561368caab492b20079fa4 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 12:45:32 -0800 Subject: [PATCH 3/8] Use devtoolset-9 Signed-off-by: Ryan Nett --- dev-containers/linux/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-containers/linux/Dockerfile b/dev-containers/linux/Dockerfile index 80cfc6f93f4..02df4cec6e9 100644 --- a/dev-containers/linux/Dockerfile +++ b/dev-containers/linux/Dockerfile @@ -6,7 +6,7 @@ RUN yum -x "$GLIBC" -y update && yum -x "$GLIBC" -y install centos-release-scl-r scl-utils \ epel-release \ java-1.8.0-openjdk-devel \ - devtoolset-7 \ + devtoolset-9 \ unzip \ which \ rh-git218 \ From fac7a835e1fbf57caf598f192750b56ece61212b Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 12:57:39 -0800 Subject: [PATCH 4/8] Fix scl enable Signed-off-by: Ryan Nett --- dev-containers/linux/scl_enable.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-containers/linux/scl_enable.sh b/dev-containers/linux/scl_enable.sh index df6a7b5f0f0..26abf8f3781 100644 --- a/dev-containers/linux/scl_enable.sh +++ b/dev-containers/linux/scl_enable.sh @@ -17,4 +17,4 @@ # */ # unset BASH_ENV PROMPT_COMMAND ENV -source scl_source enable devtoolset-7 rh-git218 \ No newline at end of file +source scl_source enable devtoolset-9 rh-git218 \ No newline at end of file From 665307962e90509081c19e8cb170a6c7f654ad60 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 18:35:53 -0800 Subject: [PATCH 5/8] Allow specifying the shell for build.sh Signed-off-by: Ryan Nett --- pom.xml | 24 +++++++++++++++++++++ tensorflow-core/tensorflow-core-api/pom.xml | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f4f1b18928b..bbdd7b0a09b 100644 --- a/pom.xml +++ b/pom.xml @@ -290,6 +290,30 @@ + + + shell-defined + + + env.TF_JAVA_SHELL + + + + ${env.TF_JAVA_SHELL} + + + + + shell-undefined + + + !env.TF_JAVA_SHELL + + + + bash + + diff --git a/tensorflow-core/tensorflow-core-api/pom.xml b/tensorflow-core/tensorflow-core-api/pom.xml index b6f9da1a2bd..9d300ac076c 100644 --- a/tensorflow-core/tensorflow-core-api/pom.xml +++ b/tensorflow-core/tensorflow-core-api/pom.xml @@ -279,7 +279,7 @@ ${javacpp.build.skip} - bash + ${build.shell} ${project.basedir}/build.sh From b6f0a6d61b40a1ab82c21d7956346d259348da3e Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 18:37:14 -0800 Subject: [PATCH 6/8] Add space dev environment Signed-off-by: Ryan Nett --- .jb-gateway/Dockerfile | 49 +++++++++++++++++++++++++++++++++++++ .jb-gateway/entrypoint.sh | 30 +++++++++++++++++++++++ .jb-gateway/install_cuda.sh | 44 +++++++++++++++++++++++++++++++++ .jb-gateway/scl_enable.sh | 20 +++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 .jb-gateway/Dockerfile create mode 100644 .jb-gateway/entrypoint.sh create mode 100644 .jb-gateway/install_cuda.sh create mode 100644 .jb-gateway/scl_enable.sh diff --git a/.jb-gateway/Dockerfile b/.jb-gateway/Dockerfile new file mode 100644 index 00000000000..02df4cec6e9 --- /dev/null +++ b/.jb-gateway/Dockerfile @@ -0,0 +1,49 @@ +FROM centos:7 + +ENV GLIBC "glibc glibc-common glibc-devel glibc-headers" +RUN yum --disablerepo updates -y install $GLIBC +RUN yum -x "$GLIBC" -y update && yum -x "$GLIBC" -y install centos-release-scl-rh && yum -x "$GLIBC" -y install \ + scl-utils \ + epel-release \ + java-1.8.0-openjdk-devel \ + devtoolset-9 \ + unzip \ + which \ + rh-git218 \ + patch \ + perl-Data-Dumper \ + python36-devel && yum -x "$GLIBC" -y install \ + python36-numpy \ + python36-pip \ + python36-six + +RUN echo "Downloading Maven" && \ + curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz && \ + tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ && \ + ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn + +RUN echo "Downloading Bazel" && \ + curl -L https://github.com/bazelbuild/bazel/releases/download/3.7.2/bazel-3.7.2-installer-linux-x86_64.sh -o bazel.sh --retry 10 && \ + bash bazel.sh + +ARG GPU=false + +ADD install_cuda.sh /install_cuda.sh +RUN chmod +x /install_cuda.sh +RUN /install_cuda.sh + +ENV JAVA_HOME /usr/lib/jvm/java-1.8.0 + +ADD scl_enable.sh /scl_enable.sh + +ADD entrypoint.sh /entrypoint +ENTRYPOINT [ "/entrypoint" ] + +ENV CI=true + +VOLUME /root/.m2 +VOLUME /root/.cache/bazel + +ENV BASH_ENV=/scl_enable.sh \ + ENV=/scl_enable.sh \ + PROMPT_COMMAND=". /scl_enable.sh" diff --git a/.jb-gateway/entrypoint.sh b/.jb-gateway/entrypoint.sh new file mode 100644 index 00000000000..17ee3c83d79 --- /dev/null +++ b/.jb-gateway/entrypoint.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# + + + + +git --version +gcc --version +mvn -version +bazel version + +set -eu +cmd="$1"; shift +exec $cmd "$@" \ No newline at end of file diff --git a/.jb-gateway/install_cuda.sh b/.jb-gateway/install_cuda.sh new file mode 100644 index 00000000000..399747e2fd8 --- /dev/null +++ b/.jb-gateway/install_cuda.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# + + + + + +echo "JAVA home is $(dirname $(dirname $(readlink $(readlink $(which javac)))))" + +if [ "$GPU" = "true" ]; then + echo Installing CUDA + curl -L https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda-repo-rhel7-11-2-local-11.2.2_460.32.03-1.x86_64.rpm -o $HOME/cuda.rpm + curl -L https://developer.download.nvidia.com/compute/redist/cudnn/v8.1.1/cudnn-11.2-linux-x64-v8.1.1.33.tgz -o $HOME/cudnn.tgz + curl -L https://developer.download.nvidia.com/compute/redist/nccl/v2.8/nccl_2.8.4-1+cuda11.2_x86_64.txz -o $HOME/nccl.txz + rpm -i $HOME/cuda.rpm + pushd /var/cuda-repo-rhel7-11-2-local/; rpm -i --nodeps cuda*.rpm libc*.rpm libn*.rpm; rm *.rpm; popd + ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/libcuda.so + ln -sf /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/libnvidia-ml.so + tar hxvf $HOME/cudnn.tgz -C /usr/local/ + tar hxvf $HOME/nccl.txz --strip-components=1 -C /usr/local/cuda/ + mv /usr/local/cuda/lib/* /usr/local/cuda/lib64/ + echo Removing downloaded archives and unused libraries to avoid running out of disk space + rm -f $HOME/*.rpm $HOME/*.tgz $HOME/*.txz $HOME/*.tar.* + rm -f $(find /usr/local/cuda/ -name '*.a' -and -not -name libcudart_static.a -and -not -name libcudadevrt.a) + rm -rf /usr/local/cuda/doc* /usr/local/cuda/libnvvp* /usr/local/cuda/nsight* /usr/local/cuda/samples* +else + echo "Skipping CUDA install" +fi \ No newline at end of file diff --git a/.jb-gateway/scl_enable.sh b/.jb-gateway/scl_enable.sh new file mode 100644 index 00000000000..26abf8f3781 --- /dev/null +++ b/.jb-gateway/scl_enable.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# +# /* Copyright 2021 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. +# ======================================================================= +# */ +# +unset BASH_ENV PROMPT_COMMAND ENV +source scl_source enable devtoolset-9 rh-git218 \ No newline at end of file From e176f941bd97ee8791cdd4ee7dd47bf374faa9d5 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 18:44:06 -0800 Subject: [PATCH 7/8] Chmod the scripts Signed-off-by: Ryan Nett --- .jb-gateway/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.jb-gateway/Dockerfile b/.jb-gateway/Dockerfile index 02df4cec6e9..56608d1cca3 100644 --- a/.jb-gateway/Dockerfile +++ b/.jb-gateway/Dockerfile @@ -29,15 +29,17 @@ RUN echo "Downloading Bazel" && \ ARG GPU=false ADD install_cuda.sh /install_cuda.sh -RUN chmod +x /install_cuda.sh +RUN chmod a+x /install_cuda.sh RUN /install_cuda.sh ENV JAVA_HOME /usr/lib/jvm/java-1.8.0 ADD scl_enable.sh /scl_enable.sh +RUN chmod a+x /scl_enable.sh ADD entrypoint.sh /entrypoint ENTRYPOINT [ "/entrypoint" ] +RUN chmod a+x /entrypoint ENV CI=true From ee348ff77e955886f1444e143cf2e91b59071c1b Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 25 Dec 2021 18:44:25 -0800 Subject: [PATCH 8/8] In both dockerfiles Signed-off-by: Ryan Nett --- dev-containers/linux/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dev-containers/linux/Dockerfile b/dev-containers/linux/Dockerfile index 02df4cec6e9..56608d1cca3 100644 --- a/dev-containers/linux/Dockerfile +++ b/dev-containers/linux/Dockerfile @@ -29,15 +29,17 @@ RUN echo "Downloading Bazel" && \ ARG GPU=false ADD install_cuda.sh /install_cuda.sh -RUN chmod +x /install_cuda.sh +RUN chmod a+x /install_cuda.sh RUN /install_cuda.sh ENV JAVA_HOME /usr/lib/jvm/java-1.8.0 ADD scl_enable.sh /scl_enable.sh +RUN chmod a+x /scl_enable.sh ADD entrypoint.sh /entrypoint ENTRYPOINT [ "/entrypoint" ] +RUN chmod a+x /entrypoint ENV CI=true