Skip to content

About the DataParallel and the assignment to anonther device of the model #295

@zdy023

Description

@zdy023

I tried to build the model on another gpu device instead of cuda:0. I tried the with statement in torch and tried to pass the device to the gpu parameter of Reader as well. In both cases, the init is ok.

However, it will reports an exception like

RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cuda:1

This seems to be caused by missing specifying the device_ids parameter in DataParallel in the 62nd line in get_detector function in detection.py and the 157th line in get_recognizer function in recognition.py.

I modified the original code such as

net = torch.nn.DataParallel(net).to(device)

to

net = torch.nn.DataParallel(net, device_ids=[torch.device(device)]).to(device)

And the exception disappeared.

Maybe you could make a little modification to fix this minor problem. Thanks very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions