{"record":{"id":"85fe294f3fe5885e","repo":"Lightning-AI/pytorch-lightning","slug":"invalid-seed-specified-via-pl-global-seed-repr-e","errorCode":null,"errorMessage":"Invalid seed specified via PL_GLOBAL_SEED: {repr(env_seed)}","messagePattern":"Invalid seed specified via PL_GLOBAL_SEED: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/utilities/seed.py","lineNumber":49,"sourceCode":"            not in bounds or cannot be cast to int, a ValueError is raised.\n        workers: if set to ``True``, will properly configure all dataloaders passed to the\n            Trainer with a ``worker_init_fn``. If the user already provides such a function\n            for their dataloaders, setting this argument will have no influence. See also:\n            :func:`~lightning.fabric.utilities.seed.pl_worker_init_function`.\n        verbose: Whether to print a message on each rank with the seed being set.\n\n    \"\"\"\n    if seed is None:\n        env_seed = os.environ.get(\"PL_GLOBAL_SEED\")\n        if env_seed is None:\n            seed = 0\n            if verbose:\n                rank_zero_warn(f\"No seed found, seed set to {seed}\")\n        else:\n            try:\n                seed = int(env_seed)\n            except ValueError:\n                raise ValueError(f\"Invalid seed specified via PL_GLOBAL_SEED: {repr(env_seed)}\")\n    elif not isinstance(seed, int):\n        seed = int(seed)\n\n    if not (min_seed_value <= seed <= max_seed_value):\n        raise ValueError(f\"{seed} is not in bounds, numpy accepts from {min_seed_value} to {max_seed_value}\")\n\n    if verbose:\n        log.info(rank_prefixed_message(f\"Seed set to {seed}\", _get_rank()))\n\n    os.environ[\"PL_GLOBAL_SEED\"] = str(seed)\n    random.seed(seed)\n    if _NUMPY_AVAILABLE:\n        import numpy as np\n\n        np.random.seed(seed)\n    torch.manual_seed(seed)\n\n    os.environ[\"PL_SEED_WORKERS\"] = f\"{int(workers)}\"","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/utilities/seed.py#L31-L67","documentation":"`seed_everything` reads the `PL_GLOBAL_SEED` environment variable to restore a previously set seed (e.g. when `reset_seed()` is called in spawned workers). The value must be parseable as an integer; if `int(env_seed)` raises ValueError, Lightning re-raises with this message showing the invalid string.","triggerScenarios":"Setting `PL_GLOBAL_SEED` to a non-numeric value (e.g. `PL_GLOBAL_SEED=random`, `PL_GLOBAL_SEED=1.5`, or an empty/whitespace string), then calling `seed_everything(...)` or anything that calls `reset_seed()` like Lightning's spawned dataloader workers.","commonSituations":"CI pipelines or launcher scripts exporting PL_GLOBAL_SEED from another variable that is empty; external tools writing float or arbitrary strings into the env var; copy-paste typos in launch commands.","solutions":["Unset or fix the env var: `PL_GLOBAL_SEED=42` (integer only) or `unset PL_GLOBAL_SEED`","Check launch scripts/CI for anything that writes PL_GLOBAL_SEED from an empty or non-integer source","Let `seed_everything(seed)` set the var itself instead of setting it manually"],"exampleFix":"# before\nPL_GLOBAL_SEED=$MY_SEED  # MY_SEED empty -> \"\"\npython train.py\n\n# after\nPL_GLOBAL_SEED=${MY_SEED:-42}\npython train.py","handlingStrategy":"validation","validationCode":"env_seed = os.environ.get(\"PL_GLOBAL_SEED\")\nif env_seed is not None:\n    try:\n        int(env_seed)\n    except ValueError:\n        del os.environ[\"PL_GLOBAL_SEED\"]  # or fix it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ever set PL_GLOBAL_SEED to integers","Audit CI/launch scripts for empty-variable expansion like PL_GLOBAL_SEED=$SEED"],"tags":["lightning","seeding","environment-variables"],"backgroundTag":"invalid-environment-variable","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}