Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

How to Run Gemma Embedding Models Using Docker

Posted on August 2, 2026

If you are looking to harness the power of Google’s Gemma models for creating high-quality text embeddings, you have come to the right place. In this guide, we will walk you through the process of setting up a containerized environment to run these models efficiently. We know that setting up machine learning environments can be a headache due to conflicting dependencies, which is why we recommend using Docker. By using the method we are about to show you, you can ensure that your environment is isolated, reproducible, and ready to handle heavy computational tasks.

First, let’s understand what we are doing. We are essentially building a specialized container based on an NVIDIA CUDA image. This container will act as a self-contained laboratory where we install Python, Git, and a high-performance inference engine called vLLM. vLLM is a crucial component here because it allows us to serve the Gemma embedding model with extremely high throughput, making it perfect for real-world applications.

Before we dive into the command, you need to make sure your system is prepared. You must have the NVIDIA Container Toolkit installed on your host machine so that Docker can communicate with your GPU. Without this, the container won’t be able to access your hardware, and the model will either fail to run or run painfully slowly on your CPU.

Now, let’s look at the specific command we will use to launch this environment. You can copy this directly into your terminal, but make sure you have your Hugging Face token ready.

docker run --rm -it \
--gpus '"device=1"' \
--ipc=host \
-p 8000:8000 \
-v "$(pwd)/run.sh:/run.sh" \
-v ~/.cache/huggingface:/root/.cache/huggingface \
-e HF_TOKEN=${HF_TOKEN:-} \
-e CUDA_VISIBLE_DEVICES=0 \
nvidia/cuda:12.6.0-devel-ubuntu22.04 \
bash -c "
apt-get update && apt-get install -y python3-pip git &&
pip3 install vllm --extra-index-url https://download.pytorch.org/whl/cu126 &&
bash /run.sh
"

We should break down this command so you understand exactly what each part does. When we use the –rm flag, we are telling Docker to automatically clean up and remove the container once we stop it. This keeps your system tidy. The -it flag allows us to interact with the container in real-time, which is helpful for debugging.

One of the most important parts is the –gpus ‘”device=1″‘ flag. This tells Docker exactly which GPU you want to use. If you have multiple cards, you can specify the index here. We also use –ipc=host, which is a technical necessity for high-performance deep learning. It allows the container to share memory more efficiently with the host, preventing “out of memory” errors during heavy data transfers.

We are also mapping ports using -p 8000:8000. This means that once the embedding server is running inside the container, you can access it from your web browser or your local code via localhost:8000.

To make this work, we use two volume mounts (-v). The first one, -v “$(pwd)/run.sh:/run.sh”, takes a script named run.sh from your current folder and puts it inside the container. You must create this script in your local directory to tell the container how to start the Gemma model. The second one, -v ~/.cache/huggingface:/root/.cache/huggingface, is a lifesaver. It maps your local Hugging Face cache to the container. This means that once you download the Gemma model, it stays on your hard drive. You won’t have to re-download several gigabytes of data every time you restart the container.

We also pass an environment variable, HF_TOKEN. Since Gemma is a gated model, you need to provide your Hugging Face authorization token to download it. We use the syntax ${HF_TOKEN:-} so that if you haven’t set this variable in your terminal, it won’t crash immediately, though the model download will eventually fail without it.

Finally, the long string at the end is the setup script. We start with a base NVIDIA image (version 12.6.0), update the package manager, install Python and Git, and then use pip to install vLLM specifically optimized for CUDA 12.6. Once everything is installed, we execute your custom /run.sh script.

By following this workflow, you are setting up a professional-grade inference server. You get the speed of vLLM, the isolation of Docker, and the convenience of persistent model caching. It is a robust way to integrate Gemma embeddings into your AI applications.

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to Run Gemma Embedding Models Using Docker
  • Deploy Nginx Rootful Container with Podman
  • How to Sandboxing Browser on Linux Desktop with Flatpak
  • How to Hardening Journald on Linux Server (Fedora/AlmaLinux)
  • Block Bad USB on Linux Server with USBGuard
  • How to Secure NetworkManager on Fedora/AlmaLinux
  • How to Secure DNS and NTP in Fedora Linux
  • How to Hardening DNF on Fedora/Almalinux
  • How to Masking & Secure Daemon in Linux Server
  • How to Hardening Mount Option in Linux Server
  • How to Secure Linux Server with AIDE
  • Auditd Custom Rules & Tips
  • Securing SSH Server with fail2ban
  • Fedora Linux Firewalld Drop Zone and Rich Rules
  • How to SSH Hardening 2026
  • How to Add Password Protection to GRUB
  • Linux Kernel Hardening: Command-line Lockdown
  • Make Linux Kernel More Safe and Hardening with Sysctl Easy Way
  • How to Lockdown Root & Wheel Group in Linux
  • How to Secure Sudo in Linux (Secure Sudo Logging & Timeout)
  • Make Fedora Login Safe with Authselect and Faillock
  • How Measure Linux Security Use OpenSCAP Lynis and Systemd
  • SELinux Make Nginx Break and How to Fix It Easy
  • How See Hidden SELinux Errors When Your Server Is Broken
  • How Fix SELinux Port Denied Error With Sealert Easy Guide
  • Kenapa Amerika Melarang Produk Robot Vacuum Cleaner & Produk Robot Lain?
  • Rayap sebagai Tanda Ada Masalah Kelembapan di Bangunan
  • Beli HP Bekas Flagship Oppo? Ini 3 Rekomendasi Terbaik yang Masih Gahar di 2026
  • Cuma 1 Jutaan! Ini 4 Rekomendasi HP POCO yang Performa Tetap Gila di 2026
  • Inilah Rekomendasi Laptop 5-6 Jutaan Paling Worth It di Pertengahan 2026, Spek Mewah Harga Ramah!
  • How to Automate Your Entire SEO Strategy Using a Swarm of 100 Free AI Agents Working in Parallel
  • How to create professional presentations easily using NotebookLM’s AI power for school projects and beyond
  • How to Master SEO Automation with Google Gemini 3.1 Flash-Lite in Google AI Studio
  • How to create viral AI video ads and complete brand assets using the Claude and Higgsfield MCP integration
  • How to Transform Your Mac Into a Supercharged AI Assistant with Perplexity Personal Computer
RSS Error: WP HTTP Error: A valid URL was not provided.
©2026 Tutorial emka | Design: Newspaperly WordPress Theme