Skip to content

Commit ac68cea

Browse files
authored
Install CUDA 11.2 in conda-cuda and libtorch containers (#616)
1 parent 4a2795e commit ac68cea

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

common/install_cuda.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,28 @@ function install_111 {
146146
ldconfig
147147
}
148148

149+
function install_112 {
150+
echo "Installing CUDA 11.2 and CuDNN"
151+
rm -rf /usr/local/cuda-11.2 /usr/local/cuda
152+
# install CUDA 11.2 in the same container
153+
wget -q https://developer.download.nvidia.com/compute/cuda/11.2.0/local_installers/cuda_11.2.0_460.27.04_linux.run
154+
chmod +x cuda_11.2.0_460.27.04_linux.run
155+
./cuda_11.2.0_460.27.04_linux.run --toolkit --silent
156+
rm -f cuda_11.2.0_460.27.04_linux.run
157+
rm -f /usr/local/cuda && ln -s /usr/local/cuda-11.2 /usr/local/cuda
158+
159+
# TODO: install CUDA 11.2 CuDNN 8.0.5, currently it's the 11.1 version
160+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
161+
mkdir tmp_cudnn && cd tmp_cudnn
162+
wget -q https://developer.download.nvidia.com/compute/redist/cudnn/v8.0.5/cudnn-11.1-linux-x64-v8.0.5.39.tgz -O cudnn-8.0.tgz
163+
tar xf cudnn-8.0.tgz
164+
cp -a cuda/include/* /usr/local/cuda/include/
165+
cp -a cuda/lib64/* /usr/local/cuda/lib64/
166+
cd ..
167+
rm -rf tmp_cudnn
168+
ldconfig
169+
}
170+
149171
function prune_92 {
150172
echo "Pruning CUDA 9.2 and CuDNN"
151173
#####################################################################################
@@ -307,6 +329,37 @@ function prune_111 {
307329
rm -rf $CUDA_BASE/libnvvp $CUDA_BASE/nsightee_plugins $CUDA_BASE/nsight-compute-2020.2.1 $CUDA_BASE/nsight-systems-2020.3.4
308330
}
309331

332+
function prune_112 {
333+
echo "Pruning CUDA 11.2 and CuDNN"
334+
#####################################################################################
335+
# CUDA 11.2 prune static libs
336+
#####################################################################################
337+
export NVPRUNE="/usr/local/cuda-11.2/bin/nvprune"
338+
export CUDA_LIB_DIR="/usr/local/cuda-11.2/lib64"
339+
340+
export GENCODE="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86"
341+
export GENCODE_CUDNN="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86"
342+
343+
if [[ -n "$OVERRIDE_GENCODE" ]]; then
344+
export GENCODE=$OVERRIDE_GENCODE
345+
fi
346+
347+
# all CUDA libs except CuDNN and CuBLAS (cudnn and cublas need arch 3.7 included)
348+
ls $CUDA_LIB_DIR/ | grep "\.a" | grep -v "culibos" | grep -v "cudart" | grep -v "cudnn" | grep -v "cublas" | grep -v "metis" \
349+
| xargs -I {} bash -c \
350+
"echo {} && $NVPRUNE $GENCODE $CUDA_LIB_DIR/{} -o $CUDA_LIB_DIR/{}"
351+
352+
# prune CuDNN and CuBLAS
353+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcudnn_static.a -o $CUDA_LIB_DIR/libcudnn_static.a
354+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublas_static.a -o $CUDA_LIB_DIR/libcublas_static.a
355+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublasLt_static.a -o $CUDA_LIB_DIR/libcublasLt_static.a
356+
357+
#####################################################################################
358+
# CUDA 11.2 prune visual tools
359+
#####################################################################################
360+
export CUDA_BASE="/usr/local/cuda-11.2/"
361+
rm -rf $CUDA_BASE/libnvvp $CUDA_BASE/nsightee_plugins $CUDA_BASE/nsight-compute-2020.3.0 $CUDA_BASE/nsight-systems-2020.4.3
362+
}
310363

311364
# idiomatic parameter and option handling in sh
312365
while test $# -gt 0
@@ -322,6 +375,8 @@ do
322375
;;
323376
11.1) install_111; prune_111
324377
;;
378+
11.2) install_112; prune_112
379+
;;
325380
*) echo "bad argument $1"; exit 1
326381
;;
327382
esac

conda/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ RUN bash ./install_cuda.sh 11.0
4949
FROM cuda as cuda111
5050
RUN bash ./install_cuda.sh 11.1
5151

52+
FROM cuda as cuda112
53+
RUN bash ./install_cuda.sh 11.2
54+
5255
# Install MNIST test data
5356
FROM base as mnist
5457
ADD ./common/install_mnist.sh install_mnist.sh
@@ -63,6 +66,7 @@ COPY --from=cuda101 /usr/local/cuda-10.1 /usr/local/cuda-10.1
6366
COPY --from=cuda102 /usr/local/cuda-10.2 /usr/local/cuda-10.2
6467
COPY --from=cuda110 /usr/local/cuda-11.0 /usr/local/cuda-11.0
6568
COPY --from=cuda111 /usr/local/cuda-11.1 /usr/local/cuda-11.1
69+
COPY --from=cuda112 /usr/local/cuda-11.2 /usr/local/cuda-11.2
6670
ADD ./java/jni.h /usr/local/include/jni.h
6771
ENV PATH /opt/conda/bin:$PATH
6872
COPY --from=mnist /usr/local/mnist /usr/local/mnist

libtorch/ubuntu16.04/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ FROM cuda as cuda111
3838
RUN bash ./install_cuda.sh 11.1
3939
RUN bash ./install_magma.sh 11.1
4040

41+
FROM cuda as cuda112
42+
RUN bash ./install_cuda.sh 11.2
43+
RUN bash ./install_magma.sh 11.2
44+
4145
FROM base as final
4246
# Install patchelf
4347
ADD ./common/install_patchelf.sh install_patchelf.sh
@@ -54,5 +58,6 @@ COPY --from=cuda101 /usr/local/cuda-10.1 /usr/local/cuda-10.1
5458
COPY --from=cuda102 /usr/local/cuda-10.2 /usr/local/cuda-10.2
5559
COPY --from=cuda110 /usr/local/cuda-11.0 /usr/local/cuda-11.0
5660
COPY --from=cuda111 /usr/local/cuda-11.1 /usr/local/cuda-11.1
61+
COPY --from=cuda112 /usr/local/cuda-11.2 /usr/local/cuda-11.2
5762
COPY --from=intel /opt/intel /opt/intel
5863
ENV CUDA_HOME /usr/local/cuda

0 commit comments

Comments
 (0)