Install Transformers to run Gemma 4 in Python
python & transformers
// what it does
Gemma 4's multimodal classes need a recent Transformers plus accelerate for device placement and timm for the vision tower. Install the latest release, since Gemma 4 support landed in newer versions; torch provides the runtime, and device_map="auto" then spreads the model across available GPUs.
// shell
$ pip install -U transformers accelerate torch timm// gotcha
An older Transformers that predates Gemma 4 fails with an unrecognized-model or unknown-architecture error when loading google/gemma-4-*. Upgrade with -U before debugging anything else.