Back to tutorials
Tutorial

Run Ollama With GPU Passthrough in Proxmox

Run Ollama in Proxmox with GPU passthrough to a VM, plus HTTPS, autostart, and a safer network setup for production use.

By Anurag Singh
Updated on Dec 04, 2026
Category: Tutorial
Share article
Run Ollama With GPU Passthrough in Proxmox

Proxmox is a clean way to keep your AI runtime separate from your web stack. You get snapshots, predictable rollbacks, and resource limits that hold.

This walkthrough shows how to run Ollama in Proxmox with GPU passthrough to an Ubuntu VM. The goal is reliable boots and a sane network path for serving local LLMs.

We’ll use a VM (not LXC). Passthrough is easier to reason about in VMs, and driver behavior is usually less fragile.

By the end, you’ll have the GPU visible in the guest, Ollama running under systemd, a quick health check, and an optional HTTPS path via a reverse proxy.

What you’ll build (and what you need)

Target setup: a Proxmox host that passes one NVIDIA GPU through to a single Ubuntu Server VM running Ollama.

Your apps can call Ollama over your LAN. If you need HTTPS, put it behind a reverse proxy.

  • Host: Proxmox VE on Intel VT-d or AMD-Vi capable hardware.
  • GPU: NVIDIA is the easiest path for Ollama GPU acceleration. (AMD can work, but driver and ROCm details vary widely.)
  • Guest: Ubuntu Server (LTS is a safe default) with enough disk for models.
  • Storage: plan for tens to hundreds of GB. Models and caches add up quickly.

Resource sizing that matches reality:

  • 7–8B models: workable on CPU, much better on GPU. Aim for 16–32 GB RAM in the VM.
  • 13–14B models: a GPU with 12–16 GB VRAM helps; 32 GB RAM recommended.
  • Quantized models ease RAM/VRAM pressure, but you’ll trade quality and sometimes speed. Plan for “good enough,” not best-case latency.

If this runs alongside websites and databases, keep it isolated. A dedicated box is the simplest long-term answer.

If you’re buying hardware for this, a dedicated server gives you stable PCIe access and predictable thermals.

If you want the provider to handle OS updates, reboots, and guardrails, managed VPS hosting is a better fit for your web tier. Keep AI on separate iron.

Step 1: Confirm IOMMU support on the Proxmox host

On the Proxmox node, confirm your CPU supports virtualization. Then confirm the kernel can see IOMMU.

egrep -i 'vmx|svm' /proc/cpuinfo | head

dmesg | egrep -i 'iommu|vt-d|amd-vi' | tail -n +1

You want logs indicating IOMMU is enabled (Intel VT-d or AMD-Vi).

If dmesg doesn’t show anything useful yet, don’t panic. This often comes down to BIOS/UEFI toggles.

Step 2: Enable IOMMU in BIOS and in Proxmox

In BIOS/UEFI, enable:

  • Intel: VT-d (and VT-x)
  • AMD: SVM (CPU virt) and IOMMU

Then enable IOMMU at boot in Proxmox.

Intel (edit /etc/default/grub):

nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt"

AMD (edit /etc/default/grub):

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"

Apply and reboot:

update-grub
reboot

After reboot, confirm again:

dmesg | egrep -i 'DMAR|IOMMU' | tail -n 50

Step 3: Identify your GPU PCI IDs and IOMMU group

You usually need to pass through the GPU and its audio function. The audio device is often on the same card.

Start by listing PCI devices:

lspci -nn | egrep -i 'vga|3d|audio'

Example output (yours will differ):

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation ... [10de:2684]
01:00.1 Audio device [0403]: NVIDIA Corporation ... [10de:22ba]

Write down the bracketed IDs, like 10de:2684 and 10de:22ba.

Next, confirm the IOMMU group. Proxmox exposes mappings in the UI.

You can also inspect sysfs:

for d in /sys/kernel/iommu_groups/*/devices/*; do
  echo "IOMMU Group ${d#*/iommu_groups/*}: $(lspci -nns ${d##*/})";
done | egrep -i 'nvidia|vga|audio'

If the GPU shares an IOMMU group with devices the host needs, passthrough becomes messy or unsafe.

On some consumer boards, that’s just how the lanes are wired. The clean fix is different hardware.

Workarounds exist, but they’re not a great production plan.

Step 4: Load VFIO modules on Proxmox

VFIO is the kernel path that assigns PCI devices to guests. Load the modules at boot.

nano /etc/modules

Add these lines if they’re not present:

vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

Now bind the GPU to vfio-pci. This prevents the Proxmox host from attaching a display driver first.

Create a modprobe rule:

nano /etc/modprobe.d/vfio.conf

Insert your device IDs (replace with your real ones):

options vfio-pci ids=10de:2684,10de:22ba disable_vga=1

On a headless Proxmox host, it also helps to stop NVIDIA drivers from grabbing the card.

Add a blacklist file:

nano /etc/modprobe.d/blacklist-nvidia.conf
blacklist nouveau
blacklist nvidia
blacklist nvidiafb

Rebuild initramfs and reboot:

update-initramfs -u
reboot

After reboot, verify VFIO owns the GPU:

lspci -nnk -s 01:00.0
lspci -nnk -s 01:00.1

You should see Kernel driver in use: vfio-pci for both functions.

Step 5: Create an Ubuntu VM and attach the GPU

Create a new VM in Proxmox (GUI or CLI). These defaults usually behave well for passthrough:

  • Machine type: q35
  • BIOS: OVMF (UEFI)
  • CPU: host
  • Disk: NVMe-backed storage if possible
  • Network: virtio

Then attach the GPU:

  • VM → Hardware → Add → PCI Device
  • Select your GPU (01:00.0)
  • Enable All Functions (so audio is included)
  • Enable PCI-Express
  • For many NVIDIA cards, also enable ROM-Bar if needed. If the VM won’t boot, revisit this toggle early.

If you prefer editing config directly, it lives at /etc/pve/qemu-server/<VMID>.conf.

The exact flags vary by card and Proxmox version. In most cases, let the GUI generate the parameters.

Step 6: Install NVIDIA drivers inside the VM

Boot the VM, install Ubuntu, then SSH in. Confirm the guest can see the GPU:

lspci | egrep -i 'nvidia|vga|3d'

Install a recommended NVIDIA driver from Ubuntu’s repositories. Package names change, so let Ubuntu tell you what it wants:

sudo apt update
sudo apt install -y ubuntu-drivers-common
sudo ubuntu-drivers devices

Then install the recommended driver (example):

sudo apt install -y nvidia-driver-XXX

Reboot:

sudo reboot

Validate with:

nvidia-smi

If nvidia-smi fails, stop and fix the driver path first. Ollama performance depends on the GPU initializing cleanly at boot.

Step 7: Install and run Ollama as a system service

Install Ollama in the VM using the official install method from Ollama’s site. On most Linux installs, it also sets up a systemd service.

Check the service:

sudo systemctl status ollama --no-pager

Enable autostart (if it isn’t already):

sudo systemctl enable --now ollama

Quick health check:

curl -s http://127.0.0.1:11434/api/tags | head

Pull a small model to validate the whole chain:

ollama pull llama3.1:8b
ollama run llama3.1:8b "Write a 3-bullet maintenance checklist for an Ubuntu VPS."

Watch GPU usage while it generates:

watch -n 1 nvidia-smi

If the model runs but the GPU stays idle, you’re effectively on CPU.

That can still be fine for light workloads. If you expected acceleration, check driver state, permissions, model build, and runtime constraints.

Disk warning: model downloads land in Ollama’s model cache. If your VM disk is small, move the cache early.

This tutorial is already on the HostMyCode blog: move Ollama’s model cache to a larger disk. The same approach applies inside a Proxmox VM.

Step 8: Make Ollama reachable (safely) from your LAN

Ollama may listen on 127.0.0.1 by default, depending on how it was installed.

It’s tempting to bind it publicly in a lab. Don’t. Treat it like a database: private by default, exposed only with intent.

First, find the VM’s LAN IP:

ip -br a

If Ollama only binds to localhost, set it to listen on the VM interface using a systemd override.

Create an override:

sudo systemctl edit ollama

Add:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Reload and restart:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Then lock it down with UFW so only your trusted subnet can reach it:

sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24 to any port 11434 proto tcp
sudo ufw enable
sudo ufw status verbose

From another machine on your LAN:

curl -s http://VM_IP:11434/api/version

If you need a more complete hardening pass for public-facing servers, start with SSH key-only access.

HostMyCode’s guide is a good baseline: set up SSH keys and disable password login.

Step 9: Add HTTPS with a reverse proxy (optional, recommended)

Many clients expect HTTPS and a stable hostname. If a web UI, workflow tool, or website feature will talk to your Ollama endpoint, put it behind a reverse proxy.

Add TLS and basic access control.

Two patterns that hold up in production:

  • Private-only: keep Ollama on LAN, and only your app server can reach it. No public DNS, no public TLS needed.
  • Public but controlled: expose it through HTTPS with an auth layer (at minimum, IP allowlist + strong random token).

If you want a known-good recipe, HostMyCode maintains a dedicated walkthrough: run Ollama behind Caddy with HTTPS.

The article targets a VPS, but the same reverse-proxy setup works inside a Proxmox VM.

Practical DNS note: if you need a hostname, register and manage it through HostMyCode domains. Then point the A/AAAA record to your reverse proxy IP (not directly to the Proxmox host).

Step 10: Reliable startup in Proxmox (no “VM booted but GPU isn’t ready” surprises)

Two failure modes show up again and again:

  • The VM boots, but the NVIDIA driver in the guest isn’t ready when Ollama starts.
  • The VM boots before networking is usable, so reverse-proxy health checks fail and the service flaps.

You can address both with a systemd drop-in. It makes Ollama wait for the GPU device node and the network.

Create a systemd override:

sudo systemctl edit ollama

Add:

[Unit]
After=network-online.target
Wants=network-online.target

[Service]
ExecStartPre=/bin/sh -c 'for i in $(seq 1 30); do test -e /dev/nvidia0 && exit 0; sleep 1; done; echo "GPU not ready"; exit 1'

Reload and restart:

sudo systemctl daemon-reload
sudo systemctl restart ollama
sudo systemctl status ollama --no-pager

If your GPU node name differs, update the test.

On some systems you’ll also see /dev/nvidiactl and /dev/nvidia-uvm.

On the Proxmox side, enable “Start at boot” for the VM. If you start multiple VMs at once, a short boot delay can help.

In general, don’t share one GPU across multiple passthrough VMs.

Quick diagnostics (save this for the next outage)

  • GPU not visible in VM: confirm Proxmox VM hardware config, IOMMU enabled, and vfio-pci binding on the host.
  • nvidia-smi fails: fix the guest driver install first. A reboot after driver install isn’t optional.
  • Ollama runs but is slow: watch nvidia-smi during generation; also confirm you’re not saturating CPU or swapping.
  • Disk fills up: models grow quietly. Keep an eye on df -h and move the model cache to larger storage.

For visibility, a lightweight monitoring agent helps. This HostMyCode piece is a solid starting point: install Netdata for real-time monitoring.

Put it in the VM for per-service detail, or on the Proxmox host for node-wide pressure.

Backing up your AI VM without guessing

You don’t need to back up every downloaded model if you can re-pull them.

You do need a plan for the parts you can’t casually recreate:

  • your prompts and app configs
  • any RAG index or vector database you add later
  • reverse proxy configs and TLS material (or the automation that recreates them)

If you’re running Ollama and related services with Docker Compose inside the VM, a restic-based approach stays predictable and fast.

This guide is worth bookmarking: Docker Compose backups with restic.

Where this fits in a real hosting stack

Most setups go sideways when the public web server and AI runtime share the same machine. Inference spikes CPU/GPU and can starve PHP-FPM, Node, or the database.

Proxmox helps because the boundaries are enforced:

  • VM 1: web/app (Nginx, PHP, Node.js)
  • VM 2: database (PostgreSQL/MySQL)
  • VM 3: AI (Ollama + models)

If you’re building this for a production website, it’s common to keep the web tier on a HostMyCode VPS.

Then run GPU inference separately (dedicated hardware or a GPU-capable host). That separation makes patching and reboots much less stressful.

Summary: a stable way to run Ollama in Proxmox

You now have GPU passthrough from Proxmox into an Ubuntu VM, NVIDIA drivers that survive reboots, and Ollama running under systemd.

You also added a startup guard that waits for the GPU.

Keep the endpoint private by default. Expose it only through an authenticated reverse proxy.

Watch disk usage before it turns into swap-driven latency.

If you want help sizing hardware, migrating an existing service, or splitting AI away from your web stack, HostMyCode can host the web tier on managed VPS hosting or deploy a dedicated inference node on dedicated servers. That pairing is usually the most predictable setup in 2026.

If you’re planning a self-hosted AI endpoint, keep your site reliable by separating inference from your web workloads. Run your websites on a HostMyCode VPS, then add dedicated servers when you’re ready for GPU passthrough and consistent performance.

FAQ

Should I use an LXC container instead of a VM for GPU passthrough?

For production, a VM is usually the safer choice. GPU passthrough in LXC can work, but driver updates and device-node handling are easier to break.

A VM gives you cleaner isolation and fewer “it broke after reboot” surprises.

Can I expose Ollama directly to the public internet?

You can, but it’s a bad default. Keep it on a private network and route requests through a reverse proxy with HTTPS and an access policy.

At minimum: an IP allowlist and strong auth.

How much disk space do I need for Ollama models?

Plan for at least 100 GB if you’re experimenting. A single quantized model can be several GB, and most people keep multiple variants.

If your VM disk is tight, move the model cache to attached storage early.

Why is Ollama slow even though I passed through a GPU?

Start with nvidia-smi. If GPU usage doesn’t climb during generation, you’re probably running CPU-only due to driver issues or runtime constraints.

Also check RAM pressure and swap activity; swapping will crush latency.

What’s the simplest way to add a UI later?

A common pattern is running Open WebUI in a separate VM or container and pointing it to your Ollama endpoint over the private network.

If you do that, keep HTTPS at the edge and avoid publishing the raw Ollama port.