tensorflow/models · error · ValueError
model_dir must be specified, but got None
Error message
model_dir must be specified, but got None
What it means
Error "model_dir must be specified, but got None" thrown in tensorflow/models.
Source
Thrown at official/core/train_lib.py:168
with self.strategy.scope():
trainer = train_utils.create_trainer(
self.params,
task,
train=train,
evaluate=evaluate,
checkpoint_exporter=self._build_best_checkpoint_exporter())
return trainer
def _build_best_checkpoint_exporter(self):
return maybe_create_best_ckpt_exporter(self.params, self.model_dir)
def _maybe_build_checkpoint_manager(
self) -> Optional[tf.train.CheckpointManager]:
"""Maybe create a CheckpointManager."""
assert self.trainer is not None
if self.trainer.checkpoint:
if self.model_dir is None:
raise ValueError('model_dir must be specified, but got None')
if (not self.strategy) or self.strategy.extended.should_checkpoint:
ckpt_path = self.model_dir
max_to_keep = self.params.trainer.max_to_keep
else:
# In multi worker training we need every worker to save checkpoint,
# because variables can trigger synchronization on read and
# synchronization needs all workers to participate. To avoid workers
# overriding each other we save to a temporary directory on non-chief
# workers.
ckpt_path = tempfile.mkdtemp()
max_to_keep = 1
checkpoint_manager = tf.train.CheckpointManager(
self.trainer.checkpoint,
directory=ckpt_path,
max_to_keep=max_to_keep,
step_counter=self.trainer.global_step,View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/core/train_lib.py:168 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/fd6f13f8f097c1cd.
Report an issue: GitHub.