Stability-AI/generative-models · error · ValueError
-n/--name and -r/--resume cannot be specified both.If you wa
Error message
-n/--name and -r/--resume cannot be specified both.If you want to resume training in a new log folder, use -n/--name in combination with --resume_from_checkpoint
What it means
main.py's CLI argument validation rejects a launch that passes both -n/--name and -r/--resume, because --resume derives the log folder from the checkpoint path while --name would create a new one — the two are mutually exclusive. The library forces you to choose: resume in-place (only --resume) or resume in a fresh folder (--name plus --resume_from_checkpoint). This check runs immediately after argument parsing, before any model or data loading.
Source
Thrown at main.py:552
# callbacks:
# callback1:
# target: importpath
# params:
# key: value
now = datetime.datetime.now().strftime("%Y-%m-%dT%H-%M-%S")
# add cwd for convenience and to make classes in this file available when
# running as `python main.py`
# (in particular `main.DataModuleFromConfig`)
sys.path.append(os.getcwd())
parser = get_parser()
opt, unknown = parser.parse_known_args()
if opt.name and opt.resume:
raise ValueError(
"-n/--name and -r/--resume cannot be specified both."
"If you want to resume training in a new log folder, "
"use -n/--name in combination with --resume_from_checkpoint"
)
melk_ckpt_name = None
name = None
if opt.resume:
if not os.path.exists(opt.resume):
raise ValueError("Cannot find {}".format(opt.resume))
if os.path.isfile(opt.resume):
paths = opt.resume.split("/")
# idx = len(paths)-paths[::-1].index("logs")+1
# logdir = "/".join(paths[:idx])
logdir = "/".join(paths[:-2])
ckpt = opt.resume
_, melk_ckpt_name = get_checkpoint_name(logdir)
else:
assert os.path.isdir(opt.resume), opt.resumeView on GitHub (pinned to e8cd657656)
Solutions
- Drop -n/--name and keep only -r/--resume to resume inside the original log folder.
- Keep -n/--name but replace -r/--resume with --resume_from_checkpoint <path> to resume into a new log folder.
- Fix the launcher script so name and resume flags are set mutually exclusively (e.g. only emit -r when -n is absent).
Example fix
// before python main.py --base configs/stable-diffusion/v1-finetune.yaml -n myrun -r logs/2024-01-01T00-00-00/checkpoints/last.ckpt // after python main.py --base configs/stable-diffusion/v1-finetune.yaml -n myrun --resume_from_checkpoint logs/2024-01-01T00-00-00/checkpoints/last.ckpt
Defensive patterns
Strategy: validation
Validate before calling
import sys
assert not ('--name' in sys.argv and '--resume' in sys.argv), \
"Use -n with --resume_from_checkpoint, not -r"
# then run: python main.py ... Prevention
- In launcher scripts, emit -r only when no -n is provided (mutually exclusive flags).
- Prefer the documented pattern: -n <new_name> + --resume_from_checkpoint <ckpt>.
When it happens
Trigger: Running the training entrypoint with both -n/--name and -r/--resume set to non-empty values, e.g. `python main.py -n myrun -r logs/2023-.../checkpoints/last.ckpt --base configs/...`. The ValueError fires in the argparse post-processing block at main.py:552 whenever `opt.name and opt.resume` are both truthy.
Common situations: Shell scripts or SLURM launchers that append `-n $RUN_NAME` unconditionally while also enabling resume; developers copying a working resume command and adding a custom run name; shell variable expansion leaving both flags populated (e.g. `-n ""` vs `-n "foo"`).
Related errors
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/be5f085c6d18bce8.
Report an issue: GitHub.