rf-detr icon indicating copy to clipboard operation
rf-detr copied to clipboard

[BUG][CLI] Fix error in cli script

Open surya3214 opened this issue 5 months ago • 6 comments
trafficstars

Description

Training with coco_dir option fails due to a small bug from L#52

NameError: name 'device_supports_cuda' is not defined

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

"python3 cli/main.py --coco_dir " won't fail anymore due to "NameError" from "device_supports_cuda"

Any specific deployment considerations

None

Docs

None

surya3214 avatar Jun 23 '25 21:06 surya3214

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 23 '25 21:06 CLAassistant

@yeldarby @probicheaux I'd appreciate if you could please check this

surya3214 avatar Jun 23 '25 21:06 surya3214

Hello @surya3214 , alternatively you can use the variable DEVICE from the config.py#L11:

def train_from_coco_dir(coco_dir: str):
    from rfdetr.config import DEVICE

    rf_detr = RFDETRBase()
    rf_detr.train(
        dataset_dir=coco_dir,
        epochs=1,
        device=DEVICE,
    )

nok avatar Jun 23 '25 23:06 nok

from rfdetr.config import DEVICE

Thanks @nok I've updated it. I see device_supports_cuda() is used in train_from_rf_project() as well. Should that be updated too?

surya3214 avatar Jun 24 '25 06:06 surya3214

Why should it not be defined by the user? e.g. In most CLI commands for DETRs we can usually set it by --device option.

parser.add_argument('--device', default='cuda',
                        help='device to use for training / testing')

Abdul-Mukit avatar Aug 12 '25 21:08 Abdul-Mukit

Why should it not be defined by the user? e.g. In most CLI commands for DETRs we can usually set it by --device option.

parser.add_argument('--device', default='cuda',
                        help='device to use for training / testing')

This PR only keeps the status quo wrt device selection and avoids build error.

While that suggestion is really useful, I shall consider it in a different PR. WDYT?

surya3214 avatar Aug 14 '25 07:08 surya3214