Lightning-AI/pytorch-lightning · error · ValueError

f"`Trainer(barebones=True, profiler={profiler!r})` was passe

Error message

f"`Trainer(barebones=True, profiler={profiler!r})` was passed." " Profiling can impact raw speed so it is disabled in barebones mode."

What it means

Trainer was created with barebones=True while a profiler was passed. Profiling instruments the training loop and impacts raw speed, so barebones mode rejects any non-None profiler.

Source

Thrown at src/lightning/pytorch/trainer/trainer.py:385

            if num_sanity_val_steps is not None and num_sanity_val_steps != 0:
                raise ValueError(
                    f"`Trainer(barebones=True, num_sanity_val_steps={num_sanity_val_steps!r})` was passed."
                    " Sanity checking can impact raw speed so it is disabled in barebones mode."
                )
            num_sanity_val_steps = 0
            # opt-ins
            if fast_dev_run is not False and fast_dev_run != 0:
                raise ValueError(
                    f"`Trainer(barebones=True, fast_dev_run={fast_dev_run!r})` was passed."
                    " Development run is not meant for raw speed evaluation so it is disabled in barebones mode."
                )
            if detect_anomaly:
                raise ValueError(
                    f"`Trainer(barebones=True, detect_anomaly={detect_anomaly!r})` was passed."
                    " Anomaly detection can impact raw speed so it is disabled in barebones mode."
                )
            if profiler is not None:
                raise ValueError(
                    f"`Trainer(barebones=True, profiler={profiler!r})` was passed."
                    " Profiling can impact raw speed so it is disabled in barebones mode."
                )
            deactivated = (
                " - Checkpointing: `Trainer(enable_checkpointing=True)`",
                " - Progress bar: `Trainer(enable_progress_bar=True)`",
                " - Model summary: `Trainer(enable_model_summary=True)`",
                " - Logging: `Trainer(logger=True)`, `Trainer(log_every_n_steps>0)`,"
                " `LightningModule.log(...)`, `LightningModule.log_dict(...)`",
                " - Sanity checking: `Trainer(num_sanity_val_steps>0)`",
                " - Development run: `Trainer(fast_dev_run=True)`",
                " - Anomaly detection: `Trainer(detect_anomaly=True)`",
                " - Profiling: `Trainer(profiler=...)`",
            )
            rank_zero_info(
                "You are running in `Trainer(barebones=True)` mode. All features that may impact raw speed have been"
                " disabled to facilitate analyzing the Trainer overhead. Specifically, the following features are"
                f" deactivated:{os.linesep}{os.linesep.join(deactivated)}"

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Remove the profiler argument when using barebones=True
  2. Pass profiler=None
  3. Run two separate Trainers: one barebones for speed, one with a profiler for profiling

Example fix

// before
trainer = Trainer(barebones=True, profiler=PyTorchProfiler(dirpath="prof"))
// after
trainer = Trainer(barebones=True)  # profile in a separate run without barebones
Defensive patterns

Strategy: validation

Validate before calling

if cfg.get("barebones") and cfg.get("profiler") is not None:
    cfg["profiler"] = None
trainer = Trainer(**cfg)

Prevention

When it happens

Trigger: Trainer(barebones=True, profiler=PyTorchProfiler(...)) or profiler="advanced" etc.

Common situations: Attempting to benchmark and profile in the same run by combining barebones=True with a profiler, which is contradictory.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/de0cedae50795a6d. Report an issue: GitHub.