Unity-Technologies/ml-agents · error · UnityTrainerException

Previous data from this run ID was not found. Train a new ru

Error message

Previous data from this run ID was not found. Train a new run by removing the --resume flag.

What it means

validate_existing_directories raises UnityTrainerException when --resume was passed but the output directory for the run ID does not exist — there is no previous data to resume from. ML-Agents requires an existing run to resume into; starting fresh must be requested by omitting --resume.

Source

Thrown at ml-agents/mlagents/trainers/directory_utils.py:33

    :param model_path: The model path specified.
    :param summary_path: The summary path to be used.
    :param resume: Whether or not the --resume flag was passed.
    :param force: Whether or not the --force flag was passed.
    :param init_path: Path to run-id dir to initialize from
    """

    output_path_exists = os.path.isdir(output_path)

    if output_path_exists:
        if not resume and not force:
            raise UnityTrainerException(
                "Previous data from this run ID was found. "
                "Either specify a new run ID, use --resume to resume this run, "
                "or use the --force parameter to overwrite existing data."
            )
    else:
        if resume:
            raise UnityTrainerException(
                "Previous data from this run ID was not found. "
                "Train a new run by removing the --resume flag."
            )

    # Verify init path if specified.
    if init_path is not None:
        if not os.path.isdir(init_path):
            raise UnityTrainerException(
                "Could not initialize from {}. "
                "Make sure models have already been saved with that run ID.".format(
                    init_path
                )
            )


def setup_init_path(
    behaviors: TrainerSettings.DefaultTrainerDict, init_dir: str
) -> None:

View on GitHub (pinned to 3ecb446f75)

Solutions

  1. Remove the --resume flag to start a fresh run (as the message suggests).
  2. Fix the run-id typo or use the run-id of the actual existing run.
  3. Copy the original results/<run_id> directory (or mount the same volume) and/or pass the correct --results-dir before resuming.

Example fix

// before
mlagents-learn config.yaml --run-id=ppo_! --resume
// after
mlagents-learn config.yaml --run-id=ppo_1 --resume
Defensive patterns

Strategy: validation

Validate before calling

import os
run_dir = os.path.join(results_dir, run_id)
if resume and not os.path.isdir(run_dir):
    raise SystemExit(f"cannot resume: {run_dir} does not exist; drop --resume or fix run-id")

Type guard

def can_resume(run_id: str, results_dir: str) -> bool:
    import os
    return os.path.isdir(os.path.join(results_dir, run_id))

Try / catch

try:
    validate_existing_directories(model_path, summary_path, run_id, resume, force, init_path)
except UnityTrainerException as e:
    if "was not found" in str(e):
        logger.error(f"No previous run at {results_dir}/{run_id}: drop --resume or fix run-id")
        raise SystemExit(1)
    raise

Prevention

When it happens

Trigger: Running mlagents-learn with --resume (or resume=True in run_training) and a run_id for which no results/<run_id> directory exists — e.g. first-time run, typo'd run_id, or different --results-dir than the original run.

Common situations: Typo in run-id when resuming; resuming on another machine or container where the results directory wasn't copied; pointing --results-dir at a different location than the original run.

Related errors


AI-assisted analysis of Unity-Technologies/ml-agents@3ecb446f75 (2026-09-02). Data as JSON: /api/errors/1a6850dc63db3287. Report an issue: GitHub.