Yes — with 38.2 GB to spare

Gemma 4 12B at Q4_K_M fits your L40S entirely on the GPU at 8K context, at an estimated 78 tokens per second. There is room for its full 256K window.

Fully on GPU 8K context Q4_K_M · 6.7 GB Apache 2.0 Released 29 May 2026 Vision

The "unified" Gemma 4: text, image and audio in one 12B that fits a 12 GB card at Q4. 140+ languages.

What hardware do I need for Gemma 4 12B? →

The VRAM budget

weights 6.7 GB
Weights 6.7 GB KV cache @ 8K 0.81 GB Runtime overhead 0.6 GB Free 38.2 GB of 46.4 GB

Quantisation ladder

QuantWeightsTotal @ 8KMax contextTok/sQualityFit
F16 22.4 GB 23.8 GB 256K 23 Reference Long context
Q8_0 11.9 GB 13.3 GB 256K 44 −0.1% ppl Long context
Q6_K 9.2 GB 10.6 GB 256K 57 −0.4% ppl Long context
Q5_K_M 7.9 GB 9.3 GB 256K 66 −0.8% ppl Long context
Q4_K_M 6.7 GB 8.2 GB 256K 78 −1.9% ppl Recommended
Q3_K_M 5.5 GB 6.9 GB 256K 96 −5.4% ppl Long context
Q2_K 4.7 GB 6.1 GB 256K 112 −15% ppl Long context

Quality is the published perplexity delta against f16 weights. Max context assumes an f16 KV cache; q8_0 roughly doubles it. This model interleaves sliding-window layers (1024 tokens, 8 of 48 layers global), which is why its cache barely grows with context.

How to run it

terminal
$ ollama pull gemma4:12b
$ OLLAMA_CONTEXT_LENGTH=8192 \
    ollama run gemma4:12b

The default. One binary, a model registry, an OpenAI-compatible port. More on Ollama.

01Download is 6.7 GB. Keep it on an SSD — a first load off a spinning disk takes minutes.
02Close anything else holding VRAM. A browser with hardware acceleration can sit on 1–2 GB.
03There is room to go to the model's full 256K context on this card.
See all models for this rig Compare with another model