Skip to content

Fix hardcoded CUDA device breaking CPU-only environments (#587)#592

Open
ShamSaleem wants to merge 2 commits into
facebookresearch:mainfrom
ShamSaleem:fix/cpu-hardcoded-cuda-587
Open

Fix hardcoded CUDA device breaking CPU-only environments (#587)#592
ShamSaleem wants to merge 2 commits into
facebookresearch:mainfrom
ShamSaleem:fix/cpu-hardcoded-cuda-587

Conversation

@ShamSaleem

Copy link
Copy Markdown

PositionEmbeddingSine and TransformerDecoder precompute their caches with a hardcoded device="cuda", and Sam3Processor defaults to "cuda", raising "Torch not compiled with CUDA enabled" on CPU-only machines. Select the device based on torch.cuda.is_available(), matching the existing convention in model_builder.py. Adds a CPU regression test.

Fixes #587

…earch#587)

PositionEmbeddingSine and TransformerDecoder precompute their caches with a hardcoded device="cuda", and Sam3Processor defaults to "cuda", raising "Torch not compiled with CUDA enabled" on CPU-only machines. Select the device based on torch.cuda.is_available(), matching the existing convention in model_builder.py. Adds a CPU regression test.

Fixes facebookresearch#587
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant