Skip to content

GPU Training Jobs ​

This guide walks through the full workflow for running a GPU training job: finding the right instance, launching it with a TTL and idle timeout, running the job in tmux so it survives your disconnect, and letting the instance manage its own lifecycle.

TTL vs idle timeout

--ttl is the hard deadline β€” it terminates the instance at launch_time + duration, never reset by stop/wake cycles. --idle-timeout stops (or hibernates) the instance when idle, saving compute cost between tasks. The timer resets each time the instance wakes. See TTL vs idle timeout for the full picture.

Find an available GPU instance ​

Start by seeing what's available and what the current Spot prices look like:

sh
# Find NVIDIA A100 instance types in us-east-1 (p4d, p4de)
truffle find a100 --region us-east-1

# Only the 80 GB A100s (p4de)
truffle find "A100-80GB" --region us-east-1

# Compare Spot prices for those types across all regions, cheapest first
truffle spot p4d.24xlarge p4de.24xlarge --sort-by-price --limit 10

# Check quota before committing
truffle quotas --regions us-east-1 --family P

truffle find shows each type's specs, on-demand price, and the AZs where it is offered; it searches only your configured region unless you pass --regions or --all-regions. truffle spot shows the current Spot price per AZ in every enabled region, next to the on-demand price and the saving. --limit 10 keeps the first 10 rows. For training jobs that can tolerate interruption, Spot typically saves 60–90%.

Launch with a completion signal ​

The cleanest pattern for training jobs is to use --on-complete terminate with a completion file. When your training script finishes, it writes a file to a known path, and spored terminates the instance automatically.

sh
spawn launch \
  --name llm-training \
  --instance-type p4d.24xlarge \
  --region us-east-1 \
  --spot \
  --ttl 24h \
  --on-complete terminate \
  --completion-file /tmp/SPAWN_COMPLETE

In your training script, add this at the end:

sh
# ... your training code ...

# Signal completion
touch /tmp/SPAWN_COMPLETE

When spored sees that file appear, it terminates the instance (after the completion delay). The TTL (--ttl 24h) acts as a hard upper bound in case something goes wrong β€” you'll never pay for more than 24 hours even if the job hangs.

Use Spot with graceful interruption handling ​

Spot instances can be interrupted by AWS with two minutes' warning. If you have a pre-stop hook that saves a checkpoint, you can resume from where you left off:

sh
spawn launch \
  --name llm-training \
  --instance-type p4d.24xlarge \
  --spot \
  --ttl 24h \
  --pre-stop "python /home/ubuntu/training/save_checkpoint.py" \
  --on-complete terminate

The --pre-stop command runs before any lifecycle-triggered shutdown β€” whether that's Spot interruption, TTL expiry, or idle timeout. spored waits up to --pre-stop-timeout for it to complete: 90 seconds by default on Spot (so it fits inside the two-minute notice), 5 minutes otherwise. Keep a Spot checkpoint well under 90 seconds.

Monitor the run ​

Check on it any time with spawn status llm-training, and read spored's lifecycle log with spawn logs llm-training --which spored. To be told when it finishes or is interrupted, add --completion-webhook-url and --spot-webhook-url with a URL you run; spored POSTs a notice to each (see Lifecycle Notifications).

Extend runtime if you need more: spawn extend llm-training 4h

Manage cost with hibernation ​

If your job has natural pauses (waiting for data, multi-phase training), consider hibernation instead of termination:

sh
spawn launch \
  --name llm-training \
  --instance-type p4d.24xlarge \
  --ttl 48h \
  --on-idle hibernate \
  --idle-timeout 30m

When the instance has been idle for 30 minutes, it hibernates β€” saving RAM state to the root volume and stopping the clock on compute billing. EBS keeps billing while it's hibernated, and the TTL keeps counting. Resume it with spawn start llm-training.

Hibernation requirements

Hibernation needs an encrypted root volume large enough for RAM; --on-idle hibernate implies --hibernate, which configures that. The AMI and instance type must also support hibernation, and not all do, so check AWS's hibernation prerequisites for your type.

Full example: multi-GPU training job ​

sh
# 1. Find 8Γ—A100 instance types, then the cheapest Spot price for one
truffle find "a100 8 gpus"
truffle spot p4d.24xlarge --sort-by-price --limit 5

# 2. Launch on Spot with checkpoint support
spawn launch \
  --name bert-finetune \
  --instance-type p4d.24xlarge \
  --region us-east-1 \
  --spot \
  --ttl 12h \
  --pre-stop "python /home/ubuntu/bert/save_checkpoint.py --emergency" \
  --on-complete terminate \
  --completion-file /tmp/SPAWN_COMPLETE

# 3. Check status any time
spawn status bert-finetune

This launch sets --ttl and no --idle-timeout, so idle detection is off: nothing will stop the instance during a quiet phase (waiting on data I/O, for example). If you do add --idle-timeout, pair it with --active-processes <name> so the instance isn't stopped while the training process runs. Names are matched exactly (pgrep -x), so use the real process name, such as python3.

Next steps ​