facebookresearch / facebookresearch/sam3
An error occurs in CPU-only environment due to hardcoded 'cuda' device
- Dominant language
- Python
- Stars
- 11.7k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
## 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
https://github.com/facebookresearch/sam3/blob/5dd401d1c5c1d5c3eedff06d41b77af824517619/sam3/model/position_encoding.py#L55
## Suggested Fix
We can resolve this by dynamically allocating the device based on an existing tensor or module parameters. For example:
```python
tensors = torch.zeros((1, 1) + size, device="cuda" if torch.cuda.is_available() else "cpu")
```
Contributor guide
Research direction
Start at sam3/model/position_encoding.py around line 55 and inspect how the tensor device is selected. Run the model in a CPU-only environment to reproduce the error; done means position encoding no longer requires CUDA and CPU execution succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- computer-vision, machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100