Skip to content

An error occurs in CPU-only environment due to hardcoded 'cuda' device #587

Description

@kawabe-jiw

Description

An error occurs when running the model in a CPU-only environment because the tensor device is hardcoded to "cuda" in sam3/model/position_encoding.py.

Location of the Issue

tensors = torch.zeros((1, 1) + size, device="cuda")

Suggested Fix

We can resolve this by dynamically allocating the device based on an existing tensor or module parameters. For example:

tensors = torch.zeros((1, 1) + size, device="cuda" if torch.cuda.is_available() else "cpu")

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