One library, one backend
Since v5, transformers supports PyTorch only; the TensorFlow and JAX/Flax backends were removed. On Apple Silicon, PyTorch with MPS is the default; for serious local inference the MLX backend (separate from transformers) wins on memory.
What you install:
transformers— the model classes, tokenizers, pipelines.torch— the backend. Pick the wheel matching your hardware (CUDA, MPS, CPU).accelerate— required for any multi-GPU / mixed-precision / device_map auto.safetensors— safe weight format. Bundled with modern transformers.- Optional:
bitsandbytesfor 8/4-bit quantization,peftfor LoRA,datasetsfor data loading.
Verify the install with transformers env
Before you debug "why is this slow," run transformers env. The output is the answer to 80% of "is my CUDA actually working" tickets — it prints the platform, Python, transformers, and torch versions; whether CUDA / MPS is available; and the GPU name. Paste this into any bug report.