# Is Transformers using GPU by default?

> Source: <https://discuss.huggingface.co/t/is-transformers-using-gpu-by-default/8500#post_9>
> Published: 2026-12-04 04:12:39+00:00

**Recommendation:** Move the model to cuda:0 once and each tokenized batch to model.device, then batch 32 sentences at a time and measure sentences per second instead of one-minute GPU utilization.
More in the playbook "Inference and self-hosting": <https://wpnews.pro/playbooks/inference-serving>

With `AutoModelForSequenceClassification.from_pretrained()` as shown above, the model starts on the CPU. Move it to `cuda:0` once, then move each batch of tokenized inputs to the same device.

For 10,000 sentences, I’d start with batches of 32 and measure sentences per second. Short, one-at-a-time predictions can make a one-minute GPU utilization average hard to interpret. [Hugging Face](https://huggingface.co/docs/transformers/pipeline_tutorial?utm_source=chatgpt.com)

``` python
import torchmodel = model.to("cuda:0").eval()batch_size = 32predictions = []with torch.inference_mode():    for start in range(0, len(sentences), batch_size):        batch = sentences[start : start + batch_size]        inputs = tokenizer(            batch, padding=True, truncation=True, return_tensors="pt"        ).to(model.device)        label_ids = model(**inputs).logits.argmax(dim=-1).cpu().tolist()        predictions.extend(model.config.id2label[i] for i in label_ids)
```

If utilization still looks low, print `model.device` and `inputs["input_ids"].device` inside the loop. Both should show `cuda:0`.
