Skip to content

Commit

Permalink
Use test -n to check the existence of CUDA_VISIBLE_DEVICES (#1204)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gpupuck authored Dec 17, 2024
1 parent 185f664 commit 5a74526
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .github/container/test-maxtext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 5a74526

Please sign in to comment.