Menu

Two PyTorch ops that stopped a CUDA text model on an Apple GPU
📰

Two PyTorch ops that stopped a CUDA text model on an Apple GPU

DEV Community: pytorch·Leo Newton·1 day ago
#49NS9T57
#devtopytorch#devto#dev#device#cuda
Reading 0:00
15s threshold

The Next-Concept Modeling eval scripts would not start on this Mac. PyTorch 2.14.1 reported the Apple GPU as available, and evaluate.py still exited with no GPU visible; pass --gpus .

The model itself did not need a rewrite. The released configs already turn FlexAttention off and use scaled dot-product attention, linear layers, embeddings, and RoPE. Three call sites assumed CUDA. Two of those assumptions are real Metal limits, and the third is just device plumbing.

The launcher only counted CUDA devices

evaluate.py asked torch.cuda.device_count() and then set CUDA_VISIBLE_DEVICES for each shard. On a Mac that count is zero, so the process stopped before it loaded a checkpoint.

A short helper keeps the NVIDIA path and adds the Apple GPU when CUDA is absent:

def accelerator () -> torch . device : if torch . cuda . is_available (): return torch . device ( " cuda " ) if torch . backends . mps . is_available (): return torch . device ( " mps " ) return torch .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.