ultralytics/ultralytics · error · NotImplementedError

This task trainer doesn't support loading cfg files

Error message

This task trainer doesn't support loading cfg files

What it means

Error "This task trainer doesn't support loading cfg files" thrown in ultralytics/ultralytics.

Source

Thrown at ultralytics/engine/trainer.py:878

            (tuple): A tuple containing:
                - metrics (dict | None): Dictionary of validation metrics, or None if validation was skipped.
                - fitness (float | None): Fitness score for the validation, or None if validation was skipped.
        """
        if self.ema and self.world_size > 1:
            # Sync EMA buffers from rank 0 to all ranks
            for buffer in self.ema.ema.buffers():
                dist.broadcast(buffer, src=0)
        metrics = self.validator(self)
        if metrics is None:
            return None, None
        fitness = metrics.pop("fitness", -self.loss.detach().cpu().numpy())  # use loss as fitness measure if not found
        if self.best_fitness is None or self.best_fitness < fitness:
            self.best_fitness = fitness
        return metrics, fitness

    def get_model(self, cfg=None, weights=None, verbose=True):
        """Get model and raise NotImplementedError for loading cfg files."""
        raise NotImplementedError("This task trainer doesn't support loading cfg files")

    def get_validator(self):
        """Raise NotImplementedError (must be implemented by subclasses)."""
        raise NotImplementedError("get_validator function not implemented in trainer")

    def get_dataloader(self, dataset_path, batch_size=16, rank=0, mode="train"):
        """Raise NotImplementedError (must return a `torch.utils.data.DataLoader` in subclasses)."""
        raise NotImplementedError("get_dataloader function not implemented in trainer")

    def build_dataset(self, img_path, mode="train", batch=None):
        """Build dataset."""
        raise NotImplementedError("build_dataset function not implemented in trainer")

    def label_loss_items(self, loss_items=None, prefix="train"):
        """Return a loss dict with labeled training loss items, or a list of loss names if loss_items is None."""
        if loss_items is None:
            return [f"{prefix}/{x}" for x in self.loss_names]
        return {f"{prefix}/{k}": round(float(v), 5) for k, v in loss_items.items()}

View on GitHub (pinned to 0449ea011c)

Solutions

  1. Load model weights (.pt file) instead of a YAML cfg for this task; e.g. model.train(data=...) with a pretrained checkpoint.
  2. Pass a YAML model config to a trainer whose task supports building from cfg, or subclass BaseTrainer and implement get_model() for your task.

When it happens

Trigger: Thrown at ultralytics/engine/trainer.py:878 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ultralytics/ultralytics@0449ea011c (2026-08-15). Data as JSON: /api/errors/35ff2d8e99d50daa. Report an issue: GitHub.