Gemma 4: Ollama, vLLM and llama.cpp setup compared
Learn Gemma 4 inference and compare DGX Spark setups, including the correction from Ollama 0.20.2 CPU results to 0.24 GPU performance.
Player not loading? Watch on YouTube
This Gemma 4 tutorial explains how a local LLM processes a prompt, then compares inference setups on an NVIDIA DGX Spark. The speaker introduces E2B, E4B, 26B MoE and 31B Dense, describing the smaller models as options for phones and other edge devices. The explanation follows tokenization, embeddings, attention and token generation, with a separate look at how the KV cache consumes memory beyond the model weights.
The setup discussion covers BF16 weights and quantized formats, including Q4_K_M GGUF and NVFP4. The speaker distinguishes Ollama's download-and-run interface from llama.cpp and vLLM, and discusses MLX for Apple silicon. For vLLM, the Docker example mounts a local Hugging Face cache, caps context at 4,096 tokens and sets GPU memory utilization to 75%.
The benchmark correction matters: the initial Ollama result of about 13.8 tokens per second used version 0.20.2 on CPU. The speaker attributes this to missing Spark CUDA libraries and reports 60.27 tokens per second on GPU after upgrading to 0.24. Other reported results include about 23 to 24 tokens per second with vLLM at BF16 and 65 with CUDA-enabled llama.cpp using a quantized 26B model. These runs use different precisions and configurations, so they do not isolate engine performance. The llama.cpp setup also requires a source build targeting the Spark's CUDA architecture 121.