{"record":{"id":"054eea412b4f166b","repo":"open-mmlab/mmdetection","slug":"device-must-be-cpu-or-gpu-but-got-device","errorCode":null,"errorMessage":"device must be 'cpu' or 'gpu', but got {device}","messagePattern":"device must be 'cpu' or 'gpu', but got (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/base_video_metric.py","lineNumber":109,"sourceCode":"    \"\"\"Collected results in distributed environments. different from the\n    function mmengine.dist.collect_results, tracking compute metrics don't use\n    paramenter size, which means length of the entire validation dataset.\n    because it's equal to video num, but compute metrics need image num.\n\n    Args:\n        results (list): Result list containing result parts to be\n            collected. Each item of ``result_part`` should be a picklable\n            object.\n        device (str): Device name. Optional values are 'cpu' and 'gpu'.\n        tmpdir (str | None): Temporal directory for collected results to\n            store. If set to None, it will create a temporal directory for it.\n            ``tmpdir`` should be None when device is 'gpu'. Defaults to None.\n\n    Returns:\n        list or None: The collected results.\n    \"\"\"\n    if device not in ['gpu', 'cpu']:\n        raise NotImplementedError(\n            f\"device must be 'cpu' or 'gpu', but got {device}\")\n\n    if device == 'gpu':\n        assert tmpdir is None, 'tmpdir should be None when device is \"gpu\"'\n        raise NotImplementedError('GPU collecting has not been supported yet')\n    else:\n        return collect_tracking_results_cpu(results, tmpdir)\n\n\ndef collect_tracking_results_cpu(result_part: list,\n                                 tmpdir: Optional[str] = None\n                                 ) -> Optional[list]:\n    \"\"\"Collect results on cpu mode.\n\n    Saves the results on different gpus to 'tmpdir' and collects them by the\n    rank 0 worker.\n\n    Args:","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/base_video_metric.py#L91-L127","documentation":"collect_tracking_results only supports device 'cpu' or 'gpu' for gathering distributed video-metric results; any other string raises NotImplementedError with the received value.","triggerScenarios":"Calling video metric evaluate() with collect_device set to something like 'cpu:gather' or a device object; misconfigured metric collect_device in configs.","commonSituations":"Custom configs overriding collect_device with an invalid string; passing torch.device instead of a plain 'cpu'/'gpu' string.","solutions":["Set collect_device='cpu' (the standard choice) in the metric config","Pass a plain string, not a torch.device object"],"exampleFix":"# before\nmetric = MOTMetric(collect_device='cuda:0')\n# after\nmetric = MOTMetric(collect_device='cpu')","handlingStrategy":"validation","validationCode":"assert collect_device in ('cpu', 'gpu'), f'bad collect_device: {collect_device}'","typeGuard":"def is_valid_collect_device(d) -> bool:\n    return isinstance(d, str) and d in ('cpu', 'gpu')","tryCatchPattern":null,"preventionTips":["Use plain 'cpu'/'gpu' strings for collect_device in metric configs","Don't pass torch.device objects"],"tags":["video-metric","collect-device","mmdetection","distributed"],"backgroundTag":"invalid-argument-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}