-
Notifications
You must be signed in to change notification settings - Fork 121
Change unknown job device #978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,107 +1,64 @@ | ||||
| #!/usr/bin/env bash | ||||
| set -euo pipefail | ||||
| #!/bin/bash | ||||
|
|
||||
| set -e | ||||
|
|
||||
| usage() { | ||||
| echo "Usage: $0 [script.sh] [cpu|gpu]" | ||||
| exit 1 | ||||
| } | ||||
|
|
||||
| [[ $# -eq 2 ]] || usage | ||||
|
|
||||
| sbatch_script="$1" | ||||
|
|
||||
| device="$2" | ||||
| job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2" | ||||
|
|
||||
| # read the body of the user script | ||||
| sbatch_body=$(<"$sbatch_script") | ||||
|
|
||||
| # common SBATCH directives | ||||
| sbatch_common_opts="\ | ||||
| #SBATCH -J shb-${sbatch_script%%.sh}-$device # job name | ||||
| #SBATCH --account=gts-sbryngelson3 # account | ||||
| #SBATCH -N1 # nodes | ||||
| #SBATCH -t 02:00:00 # walltime | ||||
| #SBATCH -q embers # QOS | ||||
| #SBATCH -o $job_slug.out # stdout+stderr | ||||
| #SBATCH --mem-per-cpu=2G # default mem (overridden below) | ||||
| " | ||||
| if [ ! -z "$1" ]; then | ||||
| sbatch_script_contents=`cat $1` | ||||
| else | ||||
| usage | ||||
| exit 1 | ||||
| fi | ||||
|
|
||||
| # CPU vs GPU overrides | ||||
| if [[ "$device" == "cpu" ]]; then | ||||
| sbatch_device_opts="\ | ||||
| sbatch_cpu_opts="\ | ||||
| #SBATCH -p cpu-small # partition | ||||
| #SBATCH --ntasks-per-node=24 # Number of cores per node required | ||||
| #SBATCH --mem-per-cpu=2G # Memory per core\ | ||||
| " | ||||
| elif [[ "$device" == "gpu" ]]; then | ||||
| sbatch_device_opts="\ | ||||
|
|
||||
| sbatch_gpu_opts="\ | ||||
| #SBATCH -CL40S | ||||
| #SBATCH --ntasks-per-node=4 # Number of cores per node required | ||||
| #SBATCH -G2\ | ||||
| " | ||||
|
|
||||
| if [ "$2" = "cpu" ]; then | ||||
| sbatch_device_opts="$sbatch_cpu_opts" | ||||
| elif [ "$2" = "gpu" ]; then | ||||
| sbatch_device_opts="$sbatch_gpu_opts" | ||||
| else | ||||
| usage | ||||
| usage | ||||
| exit 1 | ||||
| fi | ||||
|
|
||||
| # submit and capture the JobID | ||||
| JOBID=$(sbatch <<-EOT | awk '{print $4}' | ||||
| #!/usr/bin/env bash | ||||
| ${sbatch_common_opts} | ||||
| ${sbatch_device_opts} | ||||
| export job_slug="${job_slug}" | ||||
| export device="${device}" | ||||
| echo "Job slug is:" $job_slug | ||||
| echo "Device is:" $device | ||||
| set -e -x | ||||
| cd "\$SLURM_SUBMIT_DIR" | ||||
| echo "Running in \$(pwd):" | ||||
| job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2" | ||||
|
|
||||
| # load your modules & env | ||||
| . ./mfc.sh load -c p -m $device | ||||
| sbatch <<EOT | ||||
| #!/bin/bash | ||||
| #SBATCH -Jshb-$job_slug # Job name | ||||
| #SBATCH --account=gts-sbryngelson3 # charge account | ||||
| #SBATCH -N1 # Number of nodes required | ||||
| $sbatch_device_opts | ||||
| #SBATCH -t 02:00:00 # Duration of the job (Ex: 15 mins) | ||||
| #SBATCH -q embers # QOS Name | ||||
| #SBATCH -o$job_slug.out # Combined output and error messages file | ||||
| #SBATCH -W # Do not exit until the submitted job terminates. | ||||
|
||||
| #SBATCH -W # Do not exit until the submitted job terminates. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,100 +1,64 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -euo pipefail | ||||||
| #!/bin/bash | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| usage() { | ||||||
| echo "Usage: $0 [script.sh] [cpu|gpu]" | ||||||
| exit 1 | ||||||
| } | ||||||
|
|
||||||
| [[ $# -eq 2 ]] || usage | ||||||
|
|
||||||
| sbatch_script="$1" | ||||||
| device="$2" | ||||||
|
|
||||||
| job_slug="`basename "$1" | sed 's/\.sh$//' | sed 's/[^a-zA-Z0-9]/-/g'`-$2" | ||||||
|
|
||||||
| # read the body of the user script | ||||||
| sbatch_body=$(<"$sbatch_script") | ||||||
| if [ ! -z "$1" ]; then | ||||||
|
||||||
| if [ ! -z "$1" ]; then | |
| if [ -n "$1" ]; then |
Copilot
AI
Aug 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -W flag makes sbatch wait for job completion, but this removes the ability to handle job failures gracefully. The original polling mechanism provided better error handling and cleanup capabilities.
| #SBATCH -W # Do not exit until the submitted job terminates. |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,13 @@ | ||||||||||||
| #!/bin/bash | ||||||||||||
|
|
||||||||||||
| tmpbuild=/storage/scratch1/6/sbryngelson3/mytmp_build | ||||||||||||
| currentdir=$tmpbuild/run-$(( RANDOM % 900 )) | ||||||||||||
| mkdir -p $tmpbuild | ||||||||||||
| mkdir -p $currentdir | ||||||||||||
| export TMPDIR=$currentdir | ||||||||||||
|
|
||||||||||||
| n_test_threads=8 | ||||||||||||
|
|
||||||||||||
| build_opts="" | ||||||||||||
| if [ "$job_device" = "gpu" ]; then | ||||||||||||
| build_opts="--gpu" | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| ./mfc.sh test --dry-run -j $n_test_threads $build_opts | ||||||||||||
| ./mfc.sh test --dry-run -j 8 $build_opts | ||||||||||||
|
|
||||||||||||
| n_test_threads=8 | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+8
to
11
|
||||||||||||
| ./mfc.sh test --dry-run -j 8 $build_opts | |
| n_test_threads=8 | |
| n_test_threads=8 | |
| ./mfc.sh test --dry-run -j $n_test_threads $build_opts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Use
-ninstead of! -zfor checking non-empty strings. The condition should beif [ -n "$1" ]; thenfor better readability and following shell scripting best practices.