{"record":{"id":"35ff2d8e99d50daa","repo":"ultralytics/ultralytics","slug":"this-task-trainer-doesn-t-support-loading-cfg-file","errorCode":null,"errorMessage":"This task trainer doesn't support loading cfg files","messagePattern":"This task trainer doesn't support loading cfg files","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"ultralytics/engine/trainer.py","lineNumber":878,"sourceCode":"            (tuple): A tuple containing:\n                - metrics (dict | None): Dictionary of validation metrics, or None if validation was skipped.\n                - fitness (float | None): Fitness score for the validation, or None if validation was skipped.\n        \"\"\"\n        if self.ema and self.world_size > 1:\n            # Sync EMA buffers from rank 0 to all ranks\n            for buffer in self.ema.ema.buffers():\n                dist.broadcast(buffer, src=0)\n        metrics = self.validator(self)\n        if metrics is None:\n            return None, None\n        fitness = metrics.pop(\"fitness\", -self.loss.detach().cpu().numpy())  # use loss as fitness measure if not found\n        if self.best_fitness is None or self.best_fitness < fitness:\n            self.best_fitness = fitness\n        return metrics, fitness\n\n    def get_model(self, cfg=None, weights=None, verbose=True):\n        \"\"\"Get model and raise NotImplementedError for loading cfg files.\"\"\"\n        raise NotImplementedError(\"This task trainer doesn't support loading cfg files\")\n\n    def get_validator(self):\n        \"\"\"Raise NotImplementedError (must be implemented by subclasses).\"\"\"\n        raise NotImplementedError(\"get_validator function not implemented in trainer\")\n\n    def get_dataloader(self, dataset_path, batch_size=16, rank=0, mode=\"train\"):\n        \"\"\"Raise NotImplementedError (must return a `torch.utils.data.DataLoader` in subclasses).\"\"\"\n        raise NotImplementedError(\"get_dataloader function not implemented in trainer\")\n\n    def build_dataset(self, img_path, mode=\"train\", batch=None):\n        \"\"\"Build dataset.\"\"\"\n        raise NotImplementedError(\"build_dataset function not implemented in trainer\")\n\n    def label_loss_items(self, loss_items=None, prefix=\"train\"):\n        \"\"\"Return a loss dict with labeled training loss items, or a list of loss names if loss_items is None.\"\"\"\n        if loss_items is None:\n            return [f\"{prefix}/{x}\" for x in self.loss_names]\n        return {f\"{prefix}/{k}\": round(float(v), 5) for k, v in loss_items.items()}","sourceCodeStart":860,"sourceCodeEnd":896,"githubUrl":"https://github.com/ultralytics/ultralytics/blob/0449ea011cfd6c9a0d50a0bf1043aca5190cd476/ultralytics/engine/trainer.py#L860-L896","documentation":"Error \"This task trainer doesn't support loading cfg files\" thrown in ultralytics/ultralytics.","triggerScenarios":"Thrown at ultralytics/engine/trainer.py:878 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Load model weights (.pt file) instead of a YAML cfg for this task; e.g. model.train(data=...) with a pretrained checkpoint.","Pass a YAML model config to a trainer whose task supports building from cfg, or subclass BaseTrainer and implement get_model() for your task."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0449ea011cfd6c9a0d50a0bf1043aca5190cd476","analyzedAt":"2026-08-15T02:34:13.413Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}