Skip to content

Commit 32e4578

Browse files
committed
Linux dev container
Signed-off-by: Ryan Nett <[email protected]>
1 parent f07e89e commit 32e4578

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed

dev-containers/linux/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM centos:7
2+
3+
ENV GLIBC "glibc glibc-common glibc-devel glibc-headers"
4+
RUN yum --disablerepo updates -y install $GLIBC
5+
RUN yum -x "$GLIBC" -y update && yum -x "$GLIBC" -y install centos-release-scl-rh && yum -x "$GLIBC" -y install \
6+
scl-utils \
7+
epel-release \
8+
java-1.8.0-openjdk-devel \
9+
devtoolset-7 \
10+
unzip \
11+
which \
12+
rh-git218 \
13+
patch \
14+
perl-Data-Dumper \
15+
python36-devel && yum -x "$GLIBC" -y install \
16+
python36-numpy \
17+
python36-pip \
18+
python36-six
19+
20+
RUN echo "Downloading Maven" && \
21+
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 && \
22+
tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ && \
23+
ln -sf /opt/apache-maven-3.6.3/bin/mvn /usr/bin/mvn
24+
25+
RUN echo "Downloading Bazel" && \
26+
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 && \
27+
bash bazel.sh
28+
29+
ARG GPU=false
30+
31+
ADD install_cuda.sh /install_cuda.sh
32+
RUN chmod +x /install_cuda.sh
33+
RUN /install_cuda.sh
34+
35+
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0
36+
37+
ADD scl_enable.sh /scl_enable.sh
38+
39+
ADD entrypoint.sh /entrypoint
40+
ENTRYPOINT [ "/entrypoint" ]
41+
42+
ENV CI=true
43+
44+
VOLUME /root/.m2
45+
VOLUME /root/.cache/bazel
46+
47+
ENV BASH_ENV=/scl_enable.sh \
48+
ENV=/scl_enable.sh \
49+
PROMPT_COMMAND=". /scl_enable.sh"

dev-containers/linux/entrypoint.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
#
3+
# /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# =======================================================================
17+
# */
18+
#
19+
20+
21+
22+
23+
git --version
24+
gcc --version
25+
mvn -version
26+
bazel version
27+
28+
set -eu
29+
cmd="$1"; shift
30+
exec $cmd "$@"

dev-containers/linux/install_cuda.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
#
3+
# /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# =======================================================================
17+
# */
18+
#
19+
20+
21+
22+
23+
24+
echo "JAVA home is $(dirname $(dirname $(readlink $(readlink $(which javac)))))"
25+
26+
if [ "$GPU" = "true" ]; then
27+
echo Installing CUDA
28+
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
29+
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
30+
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
31+
rpm -i $HOME/cuda.rpm
32+
pushd /var/cuda-repo-rhel7-11-2-local/; rpm -i --nodeps cuda*.rpm libc*.rpm libn*.rpm; rm *.rpm; popd
33+
ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/libcuda.so
34+
ln -sf /usr/local/cuda/lib64/stubs/libnvidia-ml.so /usr/local/cuda/lib64/libnvidia-ml.so
35+
tar hxvf $HOME/cudnn.tgz -C /usr/local/
36+
tar hxvf $HOME/nccl.txz --strip-components=1 -C /usr/local/cuda/
37+
mv /usr/local/cuda/lib/* /usr/local/cuda/lib64/
38+
echo Removing downloaded archives and unused libraries to avoid running out of disk space
39+
rm -f $HOME/*.rpm $HOME/*.tgz $HOME/*.txz $HOME/*.tar.*
40+
rm -f $(find /usr/local/cuda/ -name '*.a' -and -not -name libcudart_static.a -and -not -name libcudadevrt.a)
41+
rm -rf /usr/local/cuda/doc* /usr/local/cuda/libnvvp* /usr/local/cuda/nsight* /usr/local/cuda/samples*
42+
else
43+
echo "Skipping CUDA install"
44+
fi

dev-containers/linux/scl_enable.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
# =======================================================================
17+
# */
18+
#
19+
unset BASH_ENV PROMPT_COMMAND ENV
20+
source scl_source enable devtoolset-7 rh-git218

0 commit comments

Comments
 (0)