From 5a74526aad6aee9c688f1f28ff068643366f50c9 Mon Sep 17 00:00:00 2001 From: Brian Yang <125406446+gpupuck@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:39:40 -0800 Subject: [PATCH] Use test -n to check the existence of CUDA_VISIBLE_DEVICES (#1204) With `set -u`, if CUDA_VISIBLE_DEVICES is not set outside of `test-maxtext.sh`, then `if [ "$CUDA_VISIBLE_DEVICES" != "" ]; then` will introduce `-bash: CUDA_VISIBLE_DEVICES: unbound variable` error. --- .github/container/test-maxtext.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/container/test-maxtext.sh b/.github/container/test-maxtext.sh index 96e5862f8..ebb2afcdc 100755 --- a/.github/container/test-maxtext.sh +++ b/.github/container/test-maxtext.sh @@ -174,7 +174,7 @@ if [ $DTYPE == "fp8" ]; then fi GPUS_PER_NODE=$(nvidia-smi -L | grep -c '^GPU') -if [ "$CUDA_VISIBLE_DEVICES" != "" ]; then +if [ -n "${CUDA_VISIBLE_DEVICES:-}" ]; then GPUS_PER_NODE=`python -c 'import os; x=os.environ.get("CUDA_VISIBLE_DEVICES", ""); print(len(x.split(",")))'` fi NGPUS=$((GPUS_PER_NODE * NODES))