-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.cuda
92 lines (86 loc) · 4.57 KB
/
Dockerfile.cuda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# BASE image
ARG BASE_IMAGE=ubuntu-toolbox:24.04
FROM ${BASE_IMAGE}
# CUDA and CUDNN versions
ARG CUDA_PLATFORM=ubuntu2204
ARG CUDA_RELEASE=12-2
ARG CUDNN_BRANCH=8
ARG CUDNN_RELEASE=8.9.7.29-1+cuda12.2
ARG BINARIES_DIR=/data/bins
ARG TARGETARCH=amd64
ARG RELEASE=24.04
RUN apt-get update && \
apt-get install -y build-essential openjdk-8-jdk && \
# Point java and javac commands to OpenJDK 8
update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 2000 && \
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 2000 && \
# Install GCC 8.3.x and set as default compiler (required to compile programs with nvcc on CUDA 10.1+)
if [ "${CUDA_RELEASE}" = "10-1" ]; then \
apt-get install -y gcc-8 g++-8 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 9 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 10 && \
update-alternatives --quiet --remove cpp /usr/bin/cpp && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 9 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-8 10; \
fi && \
if [ "${CUDA_RELEASE}" = "12-2" ]; then \
apt-get install -y gcc-12 g++-12 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 9 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 9 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10 && \
update-alternatives --quiet --remove cpp /usr/bin/cpp && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-13 9 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-12 10; \
fi && \
# Nsight deps workaround
echo "${CUDA_PLATFORM} :: ${RELEASE}" && \
if [ "${CUDA_PLATFORM}" = "ubuntu2204" ] && [ "${RELEASE}" = "24.04" ]; then \
wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb && \
dpkg -i libtinfo5_6.3-2ubuntu0.1_amd64.deb && \
rm libtinfo5_6.3-2ubuntu0.1_amd64.deb; \
fi && \
apt clean && rm -rd /var/lib/apt/lists/*
# Install CUDA and CUDNN runtime and development
RUN wget \
https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_PLATFORM}/x86_64/cuda-${CUDA_PLATFORM}.pin && \
mv cuda-${CUDA_PLATFORM}.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
if [ -f ${BINARIES_DIR}/faed14dd.pub ]; then \
apt-key add ${BINARIES_DIR}/faed14dd.pub; \
fi && \
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i cuda-keyring_1.1-1_all.deb && \
rm cuda-keyring_1.1-1_all.deb && \
apt-get update && apt-get install -y cuda-toolkit-${CUDA_RELEASE} && \
if [ -n "${CUDNN_RELEASE}" ]; then \
if [ -f "${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}_${CUDNN_RELEASE}_${TARGETARCH}.deb" ] && \
[ -f "${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}-dev_${CUDNN_RELEASE}_${TARGETARCH}.deb" ]; then \
dpkg -i ${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}_${CUDNN_RELEASE}_${TARGETARCH}.deb \
${BINARIES_DIR}/libcudnn${CUDNN_BRANCH}-dev_${CUDNN_RELEASE}_${TARGETARCH}.deb; \
else \
apt-get install -y libcudnn${CUDNN_BRANCH}=${CUDNN_RELEASE} \
libcudnn${CUDNN_BRANCH}-dev=${CUDNN_RELEASE}; \
fi \
else \
apt-get install -y cudnn${CUDNN_BRANCH}-cuda-${CUDA_RELEASE}; \
fi && \
apt clean && rm -rd /var/lib/apt/lists/*
# Post-install configurations
RUN echo '#Adds CUDA libraries to system path\n\
CUDA_RELEASE="'${CUDA_RELEASE}'"\n\
CUDA_VERSION_PATH=${CUDA_RELEASE%%-*}.${CUDA_RELEASE##*-}\n\
\n\
if [ "$CUDA_RELEASE" = "10-1" ]\n\
then\n\
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}\n\
fi\n\
export LD_LIBRARY_PATH=/usr/local/cuda-${CUDA_VERSION_PATH}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}\n\
export PATH=/usr/local/cuda-${CUDA_VERSION_PATH}/bin${PATH:+:${PATH}}\
' > /etc/profile.d/cuda.sh
# Cuda 10.1 cublas hotfix
RUN if [ "${CUDA_RELEASE}" = "10-1" ]; then \
cp -rP /usr/local/cuda-10.2/targets/x86_64-linux/include/* /usr/local/cuda-10.1/targets/x86_64-linux/include/ && \
cp -rP /usr/local/cuda-10.2/targets/x86_64-linux/lib/* /usr/local/cuda-10.1/targets/x86_64-linux/lib/; \
fi