|
| 1 | +ARG CUDNN_VERSION=8.9.7.29 |
| 2 | +ARG CUDNN_VERSION_AMD64=${CUDNN_VERSION} |
| 3 | +ARG CUDNN_VERSION_ARM64=${CUDNN_VERSION} |
| 4 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN=12.2 |
| 5 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_AMD64=${CUDNN_CUDA_VERSION_MAJ_MIN} |
| 6 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_ARM64=${CUDNN_CUDA_VERSION_MAJ_MIN} |
| 7 | + |
| 8 | +ARG LIBNVINFER_VERSION |
| 9 | +ARG LIBNVINFER_VERSION_AMD64=10.8.0.43 |
| 10 | +ARG LIBNVINFER_VERSION_ARM64=10.3.0.26 |
| 11 | +ARG LIBNVINFER_CUDA_VERSION_MAJ_MIN |
| 12 | +ARG LIBNVINFER_CUDA_VERSION_MAJ_MIN_AMD64=12.8 |
| 13 | +ARG LIBNVINFER_CUDA_VERSION_MAJ_MIN_ARM64=12.5 |
| 14 | + |
| 15 | +## CUDA_IMAGE |
| 16 | +## ├── nvidia/cuda:12.8.0-runtime-ubuntu22.04 |
| 17 | +## └── nvidia/cuda:12.8.0-devel-ubuntu22.04 |
| 18 | +ARG BUILD_ON_IMAGE |
| 19 | +ARG CUDNN_VERSION_MAJ=${CUDNN_VERSION%%.*} |
| 20 | +ARG CUDNN_VERSION_MAJ=${CUDNN_VERSION_MAJ:-${CUDNN_VERSION_AMD64%%.*}} |
| 21 | +ARG CUDNN_VERSION_MAJ=${CUDNN_VERSION_MAJ:-${CUDNN_VERSION_ARM64%%.*}} |
| 22 | +ARG CUDA_IMAGE_FLAVOR |
| 23 | + |
| 24 | +FROM ${BUILD_ON_IMAGE} AS cudnn8-runtime-amd64 |
| 25 | + |
| 26 | +ARG CUDNN_VERSION_AMD64 |
| 27 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_AMD64 |
| 28 | + |
| 29 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_AMD64}" |
| 30 | + |
| 31 | +ENV CUDNN_VERSION=${CUDNN_VERSION_AMD64} |
| 32 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 33 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*} |
| 34 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64}" |
| 35 | + |
| 36 | +FROM ${BUILD_ON_IMAGE} AS cudnn8-runtime-arm64 |
| 37 | + |
| 38 | +ARG CUDNN_VERSION_ARM64 |
| 39 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_ARM64 |
| 40 | + |
| 41 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_ARM64}" |
| 42 | + |
| 43 | +ENV CUDNN_VERSION=${CUDNN_VERSION_ARM64} |
| 44 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 45 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*} |
| 46 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64}" |
| 47 | + |
| 48 | +FROM ${BUILD_ON_IMAGE} AS cudnn8-devel-amd64 |
| 49 | + |
| 50 | +ARG CUDNN_VERSION_AMD64 |
| 51 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_AMD64 |
| 52 | + |
| 53 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_AMD64}" |
| 54 | + |
| 55 | +ENV CUDNN_VERSION=${CUDNN_VERSION_AMD64} |
| 56 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 57 | +ENV NV_CUDNN_DEV_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 58 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*} |
| 59 | +ENV NV_CUDNN_DEV_PACKAGE_NAME=libcudnn${NV_CUDNN_DEV_PACKAGE_VERSION%%.*}-dev |
| 60 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64}" |
| 61 | +ENV NV_CUDNN_DEV_PACKAGE="${NV_CUDNN_DEV_PACKAGE_NAME}=${NV_CUDNN_DEV_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64}" |
| 62 | + |
| 63 | +FROM ${BUILD_ON_IMAGE} AS cudnn8-devel-arm64 |
| 64 | + |
| 65 | +ARG CUDNN_VERSION_ARM64 |
| 66 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_ARM64 |
| 67 | + |
| 68 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_ARM64}" |
| 69 | + |
| 70 | +ENV CUDNN_VERSION=${CUDNN_VERSION_ARM64} |
| 71 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 72 | +ENV NV_CUDNN_DEV_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 73 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*} |
| 74 | +ENV NV_CUDNN_DEV_PACKAGE_NAME=libcudnn${NV_CUDNN_DEV_PACKAGE_VERSION%%.*}-dev |
| 75 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64}" |
| 76 | +ENV NV_CUDNN_DEV_PACKAGE="${NV_CUDNN_DEV_PACKAGE_NAME}=${NV_CUDNN_DEV_PACKAGE_VERSION}-1+cuda${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64}" |
| 77 | + |
| 78 | +FROM ${BUILD_ON_IMAGE} AS cudnn9-runtime-amd64 |
| 79 | + |
| 80 | +ARG CUDNN_VERSION_AMD64 |
| 81 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_AMD64 |
| 82 | + |
| 83 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_AMD64}" |
| 84 | + |
| 85 | +ENV CUDNN_VERSION=${CUDNN_VERSION_AMD64} |
| 86 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 87 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*}-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64%%.*} |
| 88 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1" |
| 89 | + |
| 90 | +FROM ${BUILD_ON_IMAGE} AS cudnn9-runtime-arm64 |
| 91 | + |
| 92 | +ARG CUDNN_VERSION_ARM64 |
| 93 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_ARM64 |
| 94 | + |
| 95 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_ARM64}" |
| 96 | + |
| 97 | +ENV CUDNN_VERSION=${CUDNN_VERSION_ARM64} |
| 98 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 99 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*}-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64%%.*} |
| 100 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1" |
| 101 | + |
| 102 | +FROM ${BUILD_ON_IMAGE} AS cudnn9-devel-amd64 |
| 103 | + |
| 104 | +ARG CUDNN_VERSION_AMD64 |
| 105 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_AMD64 |
| 106 | + |
| 107 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_AMD64}" |
| 108 | + |
| 109 | +ENV CUDNN_VERSION=${CUDNN_VERSION_AMD64} |
| 110 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 111 | +ENV NV_CUDNN_DEV_PACKAGE_VERSION=${CUDNN_VERSION_AMD64} |
| 112 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*}-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64%%.*} |
| 113 | +ENV NV_CUDNN_DEV_PACKAGE_NAME=libcudnn${NV_CUDNN_DEV_PACKAGE_VERSION%%.*}-dev-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_AMD64%%.*} |
| 114 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1" |
| 115 | +ENV NV_CUDNN_DEV_PACKAGE="${NV_CUDNN_DEV_PACKAGE_NAME}=${NV_CUDNN_DEV_PACKAGE_VERSION}-1" |
| 116 | + |
| 117 | +FROM ${BUILD_ON_IMAGE} AS cudnn9-devel-arm64 |
| 118 | + |
| 119 | +ARG CUDNN_VERSION_ARM64 |
| 120 | +ARG CUDNN_CUDA_VERSION_MAJ_MIN_ARM64 |
| 121 | + |
| 122 | +LABEL com.nvidia.cudnn.version="${CUDNN_VERSION_ARM64}" |
| 123 | + |
| 124 | +ENV CUDNN_VERSION=${CUDNN_VERSION_ARM64} |
| 125 | +ENV NV_CUDNN_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 126 | +ENV NV_CUDNN_DEV_PACKAGE_VERSION=${CUDNN_VERSION_ARM64} |
| 127 | +ENV NV_CUDNN_PACKAGE_NAME=libcudnn${NV_CUDNN_PACKAGE_VERSION%%.*}-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64%%.*} |
| 128 | +ENV NV_CUDNN_DEV_PACKAGE_NAME=libcudnn${NV_CUDNN_DEV_PACKAGE_VERSION%%.*}-dev-cuda-${CUDNN_CUDA_VERSION_MAJ_MIN_ARM64%%.*} |
| 129 | +ENV NV_CUDNN_PACKAGE="${NV_CUDNN_PACKAGE_NAME}=${NV_CUDNN_PACKAGE_VERSION}-1" |
| 130 | +ENV NV_CUDNN_DEV_PACKAGE="${NV_CUDNN_DEV_PACKAGE_NAME}=${NV_CUDNN_DEV_PACKAGE_VERSION}-1" |
| 131 | + |
| 132 | +FROM cudnn${CUDNN_VERSION_MAJ}-${CUDA_IMAGE_FLAVOR}-${TARGETARCH} |
| 133 | + |
| 134 | +ARG DEBIAN_FRONTEND=noninteractive |
| 135 | + |
| 136 | +ARG LIBNVINFER_VERSION_AMD64 |
| 137 | +ARG LIBNVINFER_VERSION_ARM64 |
| 138 | +ARG LIBNVINFER_CUDA_VERSION_MAJ_MIN_AMD64 |
| 139 | +ARG LIBNVINFER_CUDA_VERSION_MAJ_MIN_ARM64 |
| 140 | + |
| 141 | +ARG CUDA_HOME=/usr/local/cuda |
| 142 | +ARG NVBLAS_CONFIG_FILE=/etc/nvblas.conf |
| 143 | + |
| 144 | +ARG CUDA_IMAGE_FLAVOR |
| 145 | +ARG CUPTI_AVAILABLE |
| 146 | +ARG BUILD_START |
| 147 | + |
| 148 | +ENV CUDA_HOME=${CUDA_HOME} \ |
| 149 | + NVBLAS_CONFIG_FILE=${NVBLAS_CONFIG_FILE} \ |
| 150 | + LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${CUDA_HOME}/lib:${CUDA_HOME}/lib64${CUPTI_AVAILABLE:+:${CUDA_HOME}/extras/CUPTI/lib64} \ |
| 151 | + BUILD_DATE=${BUILD_START} |
| 152 | + |
| 153 | +RUN cpuBlasLib="$(update-alternatives --query \ |
| 154 | + libblas.so.3-$(uname -m)-linux-gnu | grep Value | cut -f2 -d' ')" \ |
| 155 | + && dpkgArch="$(dpkg --print-architecture)" \ |
| 156 | + && CUDA_VERSION_MAJ_MIN_DASH=$(echo ${CUDA_VERSION%.*} | tr '.' '-') \ |
| 157 | + ## Install the CUDA Runtime native dev links, headers |
| 158 | + && apt-get update \ |
| 159 | + && apt-get -y install --no-install-recommends \ |
| 160 | + cuda-cudart-dev-${CUDA_VERSION_MAJ_MIN_DASH}=${NV_CUDA_CUDART_VERSION} \ |
| 161 | + ## Keep apt from auto upgrading the CUDA Runtime packages |
| 162 | + && apt-mark hold \ |
| 163 | + cuda-cudart-${CUDA_VERSION_MAJ_MIN_DASH} \ |
| 164 | + cuda-cudart-dev-${CUDA_VERSION_MAJ_MIN_DASH} \ |
| 165 | + ## Unminimise if the system has been minimised |
| 166 | + && if [ ${CUDA_IMAGE_FLAVOR} = "devel" -a $(command -v unminimize) ]; then \ |
| 167 | + sed -i "s/apt-get upgrade/#apt-get upgrade/g" "$(which unminimize)"; \ |
| 168 | + yes | unminimize; \ |
| 169 | + sed -i "s/#apt-get upgrade/apt-get upgrade/g" "$(which unminimize)"; \ |
| 170 | + fi \ |
| 171 | + ## NVBLAS log configuration |
| 172 | + && touch /var/log/nvblas.log \ |
| 173 | + && chown :users /var/log/nvblas.log \ |
| 174 | + && chmod g+rw /var/log/nvblas.log \ |
| 175 | + ## NVBLAS configuration using all compute-capable GPUs |
| 176 | + && echo "NVBLAS_LOGFILE /var/log/nvblas.log" > $NVBLAS_CONFIG_FILE \ |
| 177 | + && echo "NVBLAS_CPU_BLAS_LIB $cpuBlasLib" >> $NVBLAS_CONFIG_FILE \ |
| 178 | + && echo "NVBLAS_GPU_LIST ALL" >> $NVBLAS_CONFIG_FILE \ |
| 179 | + ## Install cuDNN |
| 180 | + && apt-get -y install --no-install-recommends \ |
| 181 | + ${NV_CUDNN_PACKAGE} \ |
| 182 | + ${NV_CUDNN_DEV_PACKAGE} \ |
| 183 | + ## Keep apt from auto upgrading the cuDNN packages |
| 184 | + && apt-mark hold \ |
| 185 | + ${NV_CUDNN_PACKAGE_NAME} \ |
| 186 | + ${NV_CUDNN_DEV_PACKAGE_NAME} \ |
| 187 | + ## Install TensorRT |
| 188 | + && case "$dpkgArch" in \ |
| 189 | + amd64) LIBNVINFER_VERSION=$LIBNVINFER_VERSION_AMD64 LIBNVINFER_CUDA_VERSION_MAJ_MIN=$LIBNVINFER_CUDA_VERSION_MAJ_MIN_AMD64 ;; \ |
| 190 | + arm64) LIBNVINFER_VERSION=$LIBNVINFER_VERSION_ARM64 LIBNVINFER_CUDA_VERSION_MAJ_MIN=$LIBNVINFER_CUDA_VERSION_MAJ_MIN_ARM64 ;; \ |
| 191 | + *) echo "error: Architecture $dpkgArch unsupported"; exit 1 ;; \ |
| 192 | + esac \ |
| 193 | + ## Install development libraries and headers |
| 194 | + ## if devel-flavor of CUDA image is used |
| 195 | + && if [ ${CUDA_IMAGE_FLAVOR} = "devel" ]; then \ |
| 196 | + dev="-dev"; \ |
| 197 | + if dpkg --compare-versions ${LIBNVINFER_VERSION} gt "8.6"; then \ |
| 198 | + headers="-headers"; \ |
| 199 | + fi; \ |
| 200 | + fi \ |
| 201 | + && LIBNVINFER_VERSION_MAJ=${LIBNVINFER_VERSION%%.*} \ |
| 202 | + && CUDA_VERSION_MAJ_MIN=${LIBNVINFER_CUDA_VERSION_MAJ_MIN:-${CUDA_VERSION%.*}} \ |
| 203 | + && apt-get -y install --no-install-recommends \ |
| 204 | + libnvinfer${LIBNVINFER_VERSION_MAJ}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 205 | + libnvinfer${dev:-${LIBNVINFER_VERSION_MAJ}}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 206 | + libnvinfer${headers}${dev:-${LIBNVINFER_VERSION_MAJ}}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 207 | + libnvinfer-plugin${LIBNVINFER_VERSION_MAJ}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 208 | + libnvinfer-plugin${dev:-${LIBNVINFER_VERSION_MAJ}}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 209 | + libnvinfer${headers}-plugin${dev:-${LIBNVINFER_VERSION_MAJ}}=${LIBNVINFER_VERSION}-1+cuda${CUDA_VERSION_MAJ_MIN} \ |
| 210 | + ## Keep apt from auto upgrading the libnvinfer packages |
| 211 | + && apt-mark hold \ |
| 212 | + libnvinfer${LIBNVINFER_VERSION_MAJ} \ |
| 213 | + libnvinfer${dev:-${LIBNVINFER_VERSION_MAJ}} \ |
| 214 | + libnvinfer${headers}${dev:-${LIBNVINFER_VERSION_MAJ}} \ |
| 215 | + libnvinfer-plugin${LIBNVINFER_VERSION_MAJ} \ |
| 216 | + libnvinfer-plugin${dev:-${LIBNVINFER_VERSION_MAJ}} \ |
| 217 | + libnvinfer${headers}-plugin${dev:-${LIBNVINFER_VERSION_MAJ}} \ |
| 218 | + ## Create symlink when only newer TensorRT libraries are available |
| 219 | + && trtRunLib=$(ls -d /usr/lib/$(uname -m)-linux-gnu/* | \ |
| 220 | + grep 'libnvinfer.so.[0-9]\+$') \ |
| 221 | + && trtPluLib=$(ls -d /usr/lib/$(uname -m)-linux-gnu/* | \ |
| 222 | + grep 'libnvinfer_plugin.so.[0-9]\+$') \ |
| 223 | + && if [ "$(echo $trtRunLib | sed -n 's/.*.so.\([0-9]\+\)/\1/p')" -gt "8" ]; then \ |
| 224 | + ## TensorFlow versions < 2.18 expect TensorRT libraries version 8.6.1/8.6.2 |
| 225 | + if [ "$dpkgArch" = "amd64" ]; then \ |
| 226 | + ln -rs $trtRunLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer.so.8.6.1; \ |
| 227 | + ln -rs $trtPluLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer_plugin.so.8.6.1; \ |
| 228 | + fi; \ |
| 229 | + if [ "$dpkgArch" = "arm64" ]; then \ |
| 230 | + ln -rs $trtRunLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer.so.8.6.2; \ |
| 231 | + ln -rs $trtPluLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer_plugin.so.8.6.2; \ |
| 232 | + fi; \ |
| 233 | + ## TensorFlow versions < 2.15 expect TensorRT libraries version 8 |
| 234 | + ln -rs $trtRunLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer.so.8; \ |
| 235 | + ln -rs $trtPluLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer_plugin.so.8; \ |
| 236 | + fi \ |
| 237 | + && if [ "$(echo $trtRunLib | sed -n 's/.*.so.\([0-9]\+\)/\1/p')" -gt "7" ]; then \ |
| 238 | + ## TensorFlow versions < 2.12 expect TensorRT libraries version 7 |
| 239 | + ln -rs $trtRunLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer.so.7; \ |
| 240 | + ln -rs $trtPluLib /usr/lib/$(uname -m)-linux-gnu/libnvinfer_plugin.so.7; \ |
| 241 | + fi \ |
| 242 | + ## Clean up |
| 243 | + && rm -rf /var/lib/apt/lists/* |
0 commit comments