Skip to content

Commit 5a9698b

Browse files
authored
chore(Dockerfile): restore GPU vendor specific sections (#7911)
Until we figure out #7909 Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent 1fe0e9f commit 5a9698b

1 file changed

Lines changed: 145 additions & 2 deletions

File tree

Dockerfile

Lines changed: 145 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,152 @@ RUN apt-get update && \
1414
apt-get clean && \
1515
rm -rf /var/lib/apt/lists/*
1616

17+
# The requirements-drivers target is for BUILD_TYPE specific items. If you need to install something specific to CUDA, or specific to ROCM, it goes here.
18+
FROM requirements AS requirements-drivers
19+
20+
ARG BUILD_TYPE
21+
ARG CUDA_MAJOR_VERSION=12
22+
ARG CUDA_MINOR_VERSION=0
23+
ARG SKIP_DRIVERS=false
24+
ARG TARGETARCH
25+
ARG TARGETVARIANT
26+
ENV BUILD_TYPE=${BUILD_TYPE}
27+
ARG UBUNTU_VERSION=2404
28+
29+
RUN mkdir -p /run/localai
30+
RUN echo "default" > /run/localai/capability
31+
32+
# Vulkan requirements
33+
RUN <<EOT bash
34+
if [ "${BUILD_TYPE}" = "vulkan" ] && [ "${SKIP_DRIVERS}" = "false" ]; then
35+
apt-get update && \
36+
apt-get install -y --no-install-recommends \
37+
software-properties-common pciutils wget gpg-agent && \
38+
apt-get install -y libglm-dev cmake libxcb-dri3-0 libxcb-present0 libpciaccess0 \
39+
libpng-dev libxcb-keysyms1-dev libxcb-dri3-dev libx11-dev g++ gcc \
40+
libwayland-dev libxrandr-dev libxcb-randr0-dev libxcb-ewmh-dev \
41+
git python-is-python3 bison libx11-xcb-dev liblz4-dev libzstd-dev \
42+
ocaml-core ninja-build pkg-config libxml2-dev wayland-protocols python3-jsonschema \
43+
clang-format qtbase5-dev qt6-base-dev libxcb-glx0-dev sudo xz-utils mesa-vulkan-drivers && \
44+
wget "https://sdk.lunarg.com/sdk/download/1.4.328.1/linux/vulkansdk-linux-x86_64-1.4.328.1.tar.xz" && \
45+
tar -xf vulkansdk-linux-x86_64-1.4.328.1.tar.xz && \
46+
rm vulkansdk-linux-x86_64-1.4.328.1.tar.xz && \
47+
mkdir -p /opt/vulkan-sdk && \
48+
mv 1.4.328.1 /opt/vulkan-sdk/ && \
49+
cd /opt/vulkan-sdk/1.4.328.1 && \
50+
./vulkansdk --no-deps --maxjobs \
51+
vulkan-loader \
52+
vulkan-validationlayers \
53+
vulkan-extensionlayer \
54+
vulkan-tools \
55+
shaderc && \
56+
cp -rfv /opt/vulkan-sdk/1.4.328.1/x86_64/bin/* /usr/bin/ && \
57+
cp -rfv /opt/vulkan-sdk/1.4.328.1/x86_64/lib/* /usr/lib/x86_64-linux-gnu/ && \
58+
cp -rfv /opt/vulkan-sdk/1.4.328.1/x86_64/include/* /usr/include/ && \
59+
cp -rfv /opt/vulkan-sdk/1.4.328.1/x86_64/share/* /usr/share/ && \
60+
rm -rf /opt/vulkan-sdk && \
61+
ldconfig && \
62+
apt-get clean && \
63+
rm -rf /var/lib/apt/lists/* && \
64+
echo "vulkan" > /run/localai/capability
65+
fi
66+
EOT
67+
68+
# CuBLAS requirements
69+
RUN <<EOT bash
70+
if ( [ "${BUILD_TYPE}" = "cublas" ] || [ "${BUILD_TYPE}" = "l4t" ] ) && [ "${SKIP_DRIVERS}" = "false" ]; then
71+
apt-get update && \
72+
apt-get install -y --no-install-recommends \
73+
software-properties-common pciutils
74+
if [ "amd64" = "$TARGETARCH" ]; then
75+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/x86_64/cuda-keyring_1.1-1_all.deb
76+
fi
77+
if [ "arm64" = "$TARGETARCH" ]; then
78+
if [ "${CUDA_MAJOR_VERSION}" = "13" ]; then
79+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/sbsa/cuda-keyring_1.1-1_all.deb
80+
else
81+
curl -O https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${UBUNTU_VERSION}/arm64/cuda-keyring_1.1-1_all.deb
82+
fi
83+
fi
84+
dpkg -i cuda-keyring_1.1-1_all.deb && \
85+
rm -f cuda-keyring_1.1-1_all.deb && \
86+
apt-get update && \
87+
apt-get install -y --no-install-recommends \
88+
cuda-nvcc-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
89+
libcufft-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
90+
libcurand-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
91+
libcublas-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
92+
libcusparse-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} \
93+
libcusolver-dev-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
94+
if [ "arm64" = "$TARGETARCH" ]; then
95+
apt-get install -y --no-install-recommends \
96+
libcufile-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libcudnn9-cuda-${CUDA_MAJOR_VERSION} cuda-cupti-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION} libnvjitlink-${CUDA_MAJOR_VERSION}-${CUDA_MINOR_VERSION}
97+
fi
98+
apt-get clean && \
99+
rm -rf /var/lib/apt/lists/* && \
100+
echo "nvidia-cuda-${CUDA_MAJOR_VERSION}" > /run/localai/capability
101+
fi
102+
EOT
103+
104+
RUN <<EOT bash
105+
if [ "${BUILD_TYPE}" = "cublas" ] && [ "${TARGETARCH}" = "arm64" ]; then
106+
echo "nvidia-l4t-cuda-${CUDA_MAJOR_VERSION}" > /run/localai/capability
107+
fi
108+
EOT
109+
110+
# https://github.com/NVIDIA/Isaac-GR00T/issues/343
111+
RUN <<EOT bash
112+
if [ "${BUILD_TYPE}" = "cublas" ] && [ "${TARGETARCH}" = "arm64" ]; then
113+
wget https://developer.download.nvidia.com/compute/cudss/0.6.0/local_installers/cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0_0.6.0-1_arm64.deb && \
114+
dpkg -i cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0_0.6.0-1_arm64.deb && \
115+
cp /var/cudss-local-tegra-repo-ubuntu${UBUNTU_VERSION}-0.6.0/cudss-*-keyring.gpg /usr/share/keyrings/ && \
116+
apt-get update && apt-get -y install cudss cudss-cuda-${CUDA_MAJOR_VERSION} && \
117+
wget https://developer.download.nvidia.com/compute/nvpl/25.5/local_installers/nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5_1.0-1_arm64.deb && \
118+
dpkg -i nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5_1.0-1_arm64.deb && \
119+
cp /var/nvpl-local-repo-ubuntu${UBUNTU_VERSION}-25.5/nvpl-*-keyring.gpg /usr/share/keyrings/ && \
120+
apt-get update && apt-get install -y nvpl
121+
fi
122+
EOT
123+
124+
# If we are building with clblas support, we need the libraries for the builds
125+
RUN if [ "${BUILD_TYPE}" = "clblas" ] && [ "${SKIP_DRIVERS}" = "false" ]; then \
126+
apt-get update && \
127+
apt-get install -y --no-install-recommends \
128+
libclblast-dev && \
129+
apt-get clean && \
130+
rm -rf /var/lib/apt/lists/* \
131+
; fi
132+
133+
RUN if [ "${BUILD_TYPE}" = "hipblas" ] && [ "${SKIP_DRIVERS}" = "false" ]; then \
134+
apt-get update && \
135+
apt-get install -y --no-install-recommends \
136+
hipblas-dev \
137+
rocblas-dev && \
138+
apt-get clean && \
139+
rm -rf /var/lib/apt/lists/* && \
140+
echo "amd" > /run/localai/capability && \
141+
# I have no idea why, but the ROCM lib packages don't trigger ldconfig after they install, which results in local-ai and others not being able
142+
# to locate the libraries. We run ldconfig ourselves to work around this packaging deficiency
143+
ldconfig \
144+
; fi
145+
146+
RUN if [ "${BUILD_TYPE}" = "hipblas" ]; then \
147+
ln -s /opt/rocm-**/lib/llvm/lib/libomp.so /usr/lib/libomp.so \
148+
; fi
149+
150+
RUN expr "${BUILD_TYPE}" = intel && echo "intel" > /run/localai/capability || echo "not intel"
151+
152+
# Cuda
153+
ENV PATH=/usr/local/cuda/bin:${PATH}
154+
155+
# HipBLAS requirements
156+
ENV PATH=/opt/rocm/bin:${PATH}
157+
17158
###################################
18159
###################################
19160

20161
# The requirements-core target is common to all images. It should not be placed in requirements-core unless every single build will use it.
21-
FROM requirements AS build-requirements
162+
FROM requirements-drivers AS build-requirements
22163

23164
ARG GO_VERSION=1.25.4
24165
ARG CMAKE_VERSION=3.31.10
@@ -70,6 +211,8 @@ RUN echo "Target Architecture: $TARGETARCH"
70211
RUN echo "Target Variant: $TARGETVARIANT"
71212

72213

214+
215+
73216
WORKDIR /build
74217

75218

@@ -190,7 +333,7 @@ RUN go install github.com/mikefarah/yq/v4@latest
190333

191334
# This is the final target. The result of this target will be the image uploaded to the registry.
192335
# If you cannot find a more suitable place for an addition, this layer is a suitable place for it.
193-
FROM requirements
336+
FROM requirements-drivers
194337

195338
ENV HEALTHCHECK_ENDPOINT=http://localhost:8080/readyz
196339

0 commit comments

Comments
 (0)