Skip to content

Commit 92bddd8

Browse files
committed
Align cuda-{all-entrypoint,entrypoint}.sh
Signed-off-by: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com>
1 parent 8ea5838 commit 92bddd8

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

cuda-all-entrypoint.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
#!/bin/bash
22

3+
if ! command -v nvidia-smi &>/dev/null; then
4+
echo "Error: 'nvidia-smi' command not found."
5+
exit 1
6+
fi
7+
38
# GKE injects /usr/local/nvidia from the host but does not add it to PATH or
49
# run ldconfig for it, unlike the nvidia-container-runtime on AWS which does both.
510
if [ -d /usr/local/nvidia/bin ]; then
611
export PATH="${PATH}:/usr/local/nvidia/bin"
712
fi
813
if [ -d /usr/local/nvidia/lib64 ]; then
9-
echo /usr/local/nvidia/lib64 > /etc/ld.so.conf.d/nvidia-host.conf
14+
echo /usr/local/nvidia/lib64 >/etc/ld.so.conf.d/nvidia-host.conf
1015
ldconfig
1116
fi
1217

13-
if ! command -v nvidia-smi &>/dev/null; then
14-
echo "Error: 'nvidia-smi' command not found."
15-
exit 1
16-
fi
17-
1818
# NOTE: Given that we need to support CUDA versions earlier than CUDA 12.9.1, we
1919
# need to include the `cuda-compat-12-9` in `LD_LIBRARY_PATH` when the host CUDA
2020
# version is lower than that; whilst we shouldn't include that when CUDA is 13.0+
2121
# as otherwise it will fail due to it.
2222
if [ -d /usr/local/cuda/compat ]; then
23-
DRIVER_CUDA=$(nvidia-smi 2>/dev/null | awk '/CUDA Version/ {print $3; exit}')
23+
# Match both "CUDA Version" and "CUDA UMD Version" (on `driver-6xx` onwards)
24+
DRIVER_CUDA=$(nvidia-smi 2>/dev/null | grep -oE 'CUDA[[:space:]]+([A-Za-z]+[[:space:]])?Version:[[:space:]]*[0-9]+(\.[0-9]+)+' | grep -oE '[0-9]+(\.[0-9]+)+' | head -n1)
2425

2526
IFS='.' read -r MAJ MIN PATCH <<EOF
2627
${DRIVER_CUDA:-0.0.0}

cuda-entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
#!/bin/bash
22

3+
if ! command -v nvidia-smi &>/dev/null; then
4+
echo "Error: 'nvidia-smi' command not found."
5+
exit 1
6+
fi
7+
38
# GKE injects /usr/local/nvidia from the host but does not add it to PATH or
49
# run ldconfig for it, unlike the nvidia-container-runtime on AWS which does both.
510
if [ -d /usr/local/nvidia/bin ]; then
611
export PATH="${PATH}:/usr/local/nvidia/bin"
712
fi
813
if [ -d /usr/local/nvidia/lib64 ]; then
9-
echo /usr/local/nvidia/lib64 > /etc/ld.so.conf.d/nvidia-host.conf
14+
echo /usr/local/nvidia/lib64 >/etc/ld.so.conf.d/nvidia-host.conf
1015
ldconfig
1116
fi
1217

13-
if ! command -v nvidia-smi &>/dev/null; then
14-
echo "Error: 'nvidia-smi' command not found."
15-
exit 1
16-
fi
17-
1818
# NOTE: Given that we need to support CUDA versions earlier than CUDA 12.9.1, we
1919
# need to include the `cuda-compat-12-9` in `LD_LIBRARY_PATH` when the host CUDA
2020
# version is lower than that; whilst we shouldn't include that when CUDA is 13.0+

0 commit comments

Comments
 (0)