Sandboxes
Run a job on a rented GPU. The machine waits, suspended, for the next one.
A sandbox runs your code, and when your script exits the machine is suspended: the GPU stops billing and nothing else does, but the machine is kept. Run the same thing again and it resumes that machine instead of renting a new one, which skips most of the cold start. There is still nothing to shut down afterwards: an unused sandbox is deleted after 7 days.
Use one for anything with an end: a training run, a batch job, an experiment, a one-off script that needs a card you do not own.
factor sandbox train.py --gpu 24gb-class --streamWhat happens, in order
Your folder is uploaded
A file uploads that file. A folder uploads the folder, minus anything in
.gitignore.
A machine is rented
Matching --gpu and --zone. This is the slow part — usually under a
minute.
Setup runs, as root
Anything in --setup, before your code. Each value is one shell command
line, so apt-get update && apt-get install -y ffmpeg works as one step.
Your code runs, as you
Unprivileged. Output streams back as it is printed.
Results are collected, the machine is suspended
Everything under /factory/out is kept. Billing stops. With
--delete-on-finish, the machine is deleted instead.
Warm starts
The next run with the same settings reuses the machine instead of renting a new one: your new code is uploaded and your script runs again, on the same machine with the image already on it.
factor sandbox train.py --gpu 24gb-class # rents a machine, runs# edit train.pyfactor sandbox train.py --gpu 24gb-class # ✓ Reusing sandbox fac_01M0AM… - warm start.How fast depends on how soon you run it again:
| Run again | What happens | Starts in |
|---|---|---|
| Within 10 minutes | The machine is still up; only the container restarts | under a minute |
| Later | The machine is suspended; it is woken with your image on its disk | a few minutes |
The 10 minutes after a run are billed as running time — that is what keeps the
machine ready. After them it is suspended, and a suspended sandbox costs you
nothing. To skip the warm time, add --delete-on-finish, or run
factor stop <id> when you are done.
A warm machine checks in with Factor every few seconds. If it has stopped checking in — its network is down, say — it is not given the run: a new machine starts instead, and the silent one is suspended when its 10 minutes are up.
A machine is reused only when all of these match, because the machine was started with them:
- the command,
--setupsteps and environment --gpu(or--hard),--imageand--disk--zone, if you give one- and it is yours: another team member's sandbox is never reused for you
The code, --secret and --env may change between runs. The previous run's
--env values are removed before the new run starts.
If nothing matches, the machine's GPU has been taken since it was suspended, or it is still being suspended, a new sandbox is created as usual. To always start fresh:
factor sandbox train.py --gpu 24gb-class --freshYou can also run a suspended sandbox's last job again, with the same code:
factor start fac_01M0AM…Deleting instead of suspending
For one run:
factor sandbox train.py --gpu 24gb-class --delete-on-finishAs your default, for every run:
factor config set delete-on-finish onfactor config get delete-on-finish # onfactor sandbox train.py --delete-on-finish=off # suspend this one anywayfactor config unset delete-on-finish # back to suspendingIn a manifest, delete_on_finish: true. A flag beats the
manifest, and the manifest beats your default.
To delete a suspended sandbox now:
factor rm fac_01M0AM…Getting output back
Two separate things, and mixing them up is the most common first mistake.
Logs are what your program prints. They stream live and are kept after the run.
factor logs fac_01M0AM… -fResults are files. Write them to /factory/out and collect them after:
factor pull fac_01M0AM…Or have them mirrored to a local folder as they are written, which is what you want for checkpoints you would rather not lose to a crash:
factor sandbox train.py --gpu 24gb-class --local-volume ./checkpointsCommon flags
factor sandbox train.py \--gpu 24gb-class:2 \--zone eu \--setup "pip install -r requirements.txt" \--secret HF_TOKEN \--local-volume ./results \--stream| Flag | What it is for |
|---|---|
--gpu | 24gb-class, a6000:2, 80gb-class. See choosing hardware. |
--zone | A zone, region, country or city. factor zones lists them. |
--setup | A command to run before your code. Repeatable, runs as root. |
--secret | A stored secret to inject, by name. Repeatable. |
--env | A .env file, encrypted and injected into this run only. |
--local-volume | Mirror /factory/out into a local folder while it runs. |
-i, --image | A different base image: a published name such as python, or your own reference. factor images lists them. |
--disk | Kept for compatibility; every machine has a 100 GB system disk and most a fast /scratch disk. |
--stream | Stay attached until the run finishes. |
--detach | Return as soon as the machine exists. |
--delete-on-finish | Delete the machine when the run ends instead of suspending it. =off overrides a default of on. |
--fresh | Start a new machine even if a suspended one could be reused. |
Passing arguments to your program
Everything after -- goes to your code untouched:
factor sandbox train.py -- --epochs 50 --lr 3e-4Examples
factor sandbox ./project \--gpu 24gb-class \--setup "pip install -r requirements.txt" \--streamprintf '%s' "$HF_TOKEN" | factor secret set HF_TOKEN factor sandbox ./finetune \--gpu 24gb-class:2 \--setup "pip install -r requirements.txt" \--secret HF_TOKEN \--local-volume ./checkpoints \--streamid=$(factor sandbox ./sweep --gpu 24gb-class --detach --json | jq -r .id)factor logs "$id" -ffactor pull "$id"Costs
Billed per second, from the machine being ready to your script exiting, plus the warm minutes after it (see warm starts). A sandbox that fails after ten seconds costs ten seconds and its warm time. Nothing accrues while you are writing the code, and nothing accrues once it is suspended: keeping a suspended sandbox for its next run costs you nothing.
When you want a factory instead
If files should still be there after the work stops — an inference server, a dev box, anything you redeploy from a repository — that is a factory.