Lightning-AI/pytorch-lightning · error · MisconfigurationException
Providing log_model={log_model} and offline={offline} is an
Error message
Providing log_model={log_model} and offline={offline} is an invalid configuration since model checkpoints cannot be uploaded in offline mode.
Hint: Set `offline=False` to log your model. What it means
MisconfigurationException from WandbLogger.__init__: offline=True (no network run) combined with log_model set to a truthy value is rejected because model checkpoints cannot be uploaded to W&B without an online run.
Source
Thrown at src/lightning/pytorch/loggers/wandb.py:315
save_dir: _PATH = ".",
version: Optional[str] = None,
offline: bool = False,
dir: Optional[_PATH] = None,
id: Optional[str] = None,
anonymous: Optional[bool] = None,
project: Optional[str] = None,
log_model: Union[Literal["all"], bool] = False,
experiment: Union["Run", "RunDisabled", None] = None,
prefix: str = "",
checkpoint_name: Optional[str] = None,
add_file_policy: Literal["mutable", "immutable"] = "mutable",
**kwargs: Any,
) -> None:
if not _WANDB_AVAILABLE:
raise ModuleNotFoundError(str(_WANDB_AVAILABLE))
if offline and log_model:
raise MisconfigurationException(
f"Providing log_model={log_model} and offline={offline} is an invalid configuration"
" since model checkpoints cannot be uploaded in offline mode.\n"
"Hint: Set `offline=False` to log your model."
)
super().__init__()
self._offline = offline
self._log_model = log_model
self._prefix = prefix
self._experiment = experiment
self._logged_model_time: dict[str, float] = {}
self._checkpoint_callbacks: dict[int, ModelCheckpoint] = {}
self.add_file_policy = add_file_policy
# paths are processed as strings
if save_dir is not None:
save_dir = os.fspath(save_dir)
elif dir is not None:View on GitHub (pinned to 9fed5c27d2)
Solutions
- Set offline=False (with WANDB_API_KEY configured) if you need model uploads
- Keep offline=True but pass log_model=False / omit log_model
- Log checkpoints manually to a local dir and upload later with wandb sync when online
Example fix
# before logger = WandbLogger(offline=True, log_model='all') # after (choose one) logger = WandbLogger(offline=True) # no ckpt upload logger = WandbLogger(offline=False, log_model='all') # online upload
Defensive patterns
Strategy: validation
Validate before calling
if cfg.wandb.offline and cfg.wandb.log_model:
raise ValueError("offline=True cannot be combined with log_model") Prevention
- Guard config combos in a validate() step before constructing loggers
- Default log_model to False in offline/CI profiles
When it happens
Trigger: WandbLogger(save_dir='./off', offline=True, log_model='all') (or log_model=True/every/interval) — any truthy log_model with offline truthy.
Common situations: Air-gapped or CI environments set offline=True while the code (copied from an online example) enables checkpoint uploading via log_model.
Related errors
- You have set `accumulate_grad_batches` and are using the `Gr
- You set `.load_from_checkpoint(..., strict={strict!r})` whic
- Experiment is not initialized
- `synchronous` requires mlflow>=2.8.0
- NeptuneLogger is no longer supported. Neptune has been sunse
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/65b247992e4c3277.
Report an issue: GitHub.