Skip to content

Commit 5a74526

Browse files
authored
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.
1 parent 185f664 commit 5a74526

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

.github/container/test-maxtext.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ if [ $DTYPE == "fp8" ]; then
174174
fi
175175

176176
GPUS_PER_NODE=$(nvidia-smi -L | grep -c '^GPU')
177-
if [ "$CUDA_VISIBLE_DEVICES" != "" ]; then
177+
if [ -n "${CUDA_VISIBLE_DEVICES:-}" ]; then
178178
GPUS_PER_NODE=`python -c 'import os; x=os.environ.get("CUDA_VISIBLE_DEVICES", ""); print(len(x.split(",")))'`
179179
fi
180180
NGPUS=$((GPUS_PER_NODE * NODES))

0 commit comments

Comments
 (0)