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
- Remove the profiler argument when using barebones=True
- Pass profiler=None
- 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
- Profile and benchmark in separate Trainer instances/runs
- Wrap Trainer construction from a config dict so incompatible keys can be sanitized centrally
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
- f"`Trainer(barebones=True, log_every_n_steps={log_every_n_st
- f"`Trainer(barebones=True, enable_model_summary={enable_mode
- f"`Trainer(barebones=True, num_sanity_val_steps={num_sanity_
- f"`Trainer(barebones=True, fast_dev_run={fast_dev_run!r})` w
- f"`Trainer(barebones=True, detect_anomaly={detect_anomaly!r}
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/de0cedae50795a6d.
Report an issue: GitHub.