sgl-project/sglang · info

CUDA coredump env var {key} is already set to '{os.environ[k

Error message

CUDA coredump env var {key} is already set to '{os.environ[key]}', skipping injection of '{value}'.

What it means

sglang's CUDA coredump helper injects CUDA_COREDUMP_* env vars to configure crash dumps. If one of these is already present in the environment, injection is skipped for that key and this warning tells you the pre-existing value wins.

Source

Thrown at python/sglang/srt/debug_utils/cuda_coredump.py:66

        return os.path.join(base, f"{run_id}-{attempt}")
    return base


def _inject_env():
    """Inject CUDA coredump environment variables into the current process.
    If a CUDA_* variable is already present, skip it and log a warning."""
    dump_dir = get_dump_dir()
    os.makedirs(dump_dir, exist_ok=True)

    env_vars = {
        "CUDA_ENABLE_COREDUMP_ON_EXCEPTION": "1",
        "CUDA_COREDUMP_SHOW_PROGRESS": "1",
        "CUDA_COREDUMP_GENERATION_FLAGS": _CUDA_COREDUMP_FLAGS,
        "CUDA_COREDUMP_FILE": f"{dump_dir}/cuda_coredump_%h.%p.%t",
    }
    for key, value in env_vars.items():
        if key in os.environ:
            warnings.warn(
                f"CUDA coredump env var {key} is already set to "
                f"'{os.environ[key]}', skipping injection of '{value}'.",
                stacklevel=2,
            )
        else:
            os.environ[key] = value


def cleanup_dump_dir():
    """Remove stale coredump files from the dump directory."""
    dump_dir = get_dump_dir()
    for f in glob.glob(os.path.join(dump_dir, "cuda_coredump_*")):
        os.remove(f)


def report():
    """Log any CUDA coredump files found after a test failure."""
    dump_dir = get_dump_dir()

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify the existing value matches your intended dump location/flags
  2. Unset the preexisting var (unset CUDA_COREDUMP_FILE ...) before enabling sglang's helper so it can inject its defaults
  3. Keep your value and ignore the warning if the custom configuration is intentional

Example fix

# before
CUDA_COREDUMP_FILE=/custom/core.%p python app.py
# after
unset CUDA_COREDUMP_FILE && python app.py  # let sglang inject defaults
Defensive patterns

Strategy: validation

Validate before calling

for k in ("CUDA_COREDUMP_FILE", "CUDA_COREDUMP_GENERATION_FLAGS", "CUDA_COREDUMP_SHOW_PROGRESS"):
    os.environ.pop(k, None)  # before enabling sglang coredump helper

Prevention

When it happens

Trigger: Enabling the coredump debug utility while CUDA_COREDUMP_FILE, CUDA_COREDUMP_GENERATION_FLAGS, CUDA_COREDUMP_SHOW_PROGRESS, or CUDA_COREDUMP_PIPE limits are already exported (common in CI or container images that preconfigure coredumps).

Common situations: Containers/base images with CUDA coredump preconfigured; a previous coredump session whose exports persisted into the shell; ops runbooks setting dump file patterns globally.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/f2546601f1fd20d8. Report an issue: GitHub.