Skip to content

Don't hardcode torch supported devices (XPU device support) #436

@DatCaptainHorse

Description

@DatCaptainHorse

Search before asking

  • I have searched the RF-DETR issues and found no similar bug report.

Bug

pydantic_core._pydantic_core.ValidationError: 1 validation error for RFDETRBaseConfig
device
  Input should be 'cpu', 'cuda' or 'mps' [type=literal_error, input_value='xpu', input_type=str]

Making hardcoded assumptions is bad, just let people input whatever device they have, unless you plan on updating the codebase 5 years later as well with possibly new devices popping up in torch 😅

Environment

  • RF-DETR latest as of 3.11.2025
  • OS CachyOS Linux
  • Python 3.13
  • PyTorch 2.9
  • CUDA/cuDNN
  • GPU/CPU Intel Arc A770 16GB - Ryzen 5950X

Minimal Reproducible Example

import supervision as sv
from rfdetr import RFDETRBase
from rfdetr.util.coco_classes import COCO_CLASSES

model = RFDETRBase(device="xpu")

def callback(frame, index):
    detections = model.predict(frame[:, :, ::-1], threshold=0.5)

    labels = [
        f"{COCO_CLASSES[class_id]} {confidence:.2f}"
        for class_id, confidence
        in zip(detections.class_id, detections.confidence)
    ]

    annotated_frame = frame.copy()
    annotated_frame = sv.BoxAnnotator().annotate(annotated_frame, detections)
    annotated_frame = sv.LabelAnnotator().annotate(annotated_frame, detections, labels)
    return annotated_frame

sv.process_video(
    source_path="<SOURCE>",
    target_path="./output_det.mkv",
    callback=callback
)

Additional

No response

Are you willing to submit a PR?

  • Yes, I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions