Skip to content

Commit

Permalink
new autobot launch script
Browse files Browse the repository at this point in the history
  • Loading branch information
beneisner committed Jan 4, 2025
1 parent 513b819 commit b8fe367
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions cluster/launch_autobot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# We want an option to take GPU_TYPE and NUM_GPUS as arguments. They should be flags.

# Parse the arguments
while getopts ":t:n:" opt; do
case $opt in
t) GPU_TYPE=$OPTARG ;;
n) NUM_GPUS=$OPTARG ;;
\?) echo "Invalid option -$OPTARG" >&2; exit 1 ;;
esac
done

# Shift the arguments so that $@ contains only the command to run
shift $((OPTIND-1))

# Default values
GPU_TYPE=${GPU_TYPE:-rtx3090}
NUM_GPUS=${NUM_GPUS:-1}


OUTPUT=$(python -m rpad.core.autobot available ${GPU_TYPE} ${NUM_GPUS} --quiet --local)

# Split the output on the colon
NODE=${OUTPUT%%:*}
GPU_INDICES=${OUTPUT#*:}
COMMAND=$@

# Print the results (optional)
echo -e "######################################"
echo -e "Launching job:"
echo -e " Node:\t\t${NODE}"
echo -e " GPU type:\t${GPU_TYPE}"
echo -e " GPU indices:\t${GPU_INDICES}"
echo -e " Command:\t${COMMAND}"
echo -e "######################################"

# For some reason, the -c option causes an error "option requires an argument", but it still works.
ssh -t ${NODE} bash -ic "
# Setup env.
cd ~/code/rpad/python_ml_project_template
source ~/miniconda3/bin/activate
conda activate python_ml_project_template
# Now, treat the rest of the command line arguments as the command to run.
CUDA_VISIBLE_DEVICES=$GPU_INDICES $COMMAND
echo '######################################'
echo 'Job finished.'
echo '######################################'
# Deactivate the conda environment.
conda deactivate
"

0 comments on commit b8fe367

Please sign in to comment.