Skip to content

Instantly share code, notes, and snippets.

@Chuckame
Last active November 13, 2025 21:12
Show Gist options
  • Select an option

  • Save Chuckame/cd7fdcc86e23dc87b4299601e51e3d29 to your computer and use it in GitHub Desktop.

Select an option

Save Chuckame/cd7fdcc86e23dc87b4299601e51e3d29 to your computer and use it in GitHub Desktop.
Setup Proxmox GPU passthrough on lenovo m720q for Docker usage like ollama

Allow GPU passthrough

Done in proxmox 9

  1. Append the following in /etc/kernel/cmdline: iommu=pt (no need of pcie_acs_override=downstream,multifunction as we don't need separate iommu groups, no need of intel_iommu=on for kernels >=6.8)
  2. If you have systemd-boot: proxmox-boot-tool refresh
  3. nano /etc/modules-load.d/pci-pass-through.conf:
vfio
vfio_iommu_type1
vfio_pci
  1. update-initramfs -u -k all
  2. Disable actual drivers to use the GPU to not interfere with passthrough: nano /etc/modprobe.d/nvidia-passthrough-blacklist.conf:
blacklist nouveau
blacklist nvidia*
  1. Reboot
  2. dmesg | grep -e DMAR should return DMAR: IOMMU enabled or DMAR: Intel(R) Virtualization Technology for Directed I/O
  3. Create PCI device Datacenter > PCI devices > Add and select the GPU (you should see the warning not in a separate IOMMU group, make sure this is intended., but it doesn't matter, as the only device in the IOMMU group is the GPU itself, so no security risk)

Create Docker VM

  • Execute bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/vm/docker-vm.sh)"
    • CPU: host
    • Machine: q35
    • Bios: SeaBIOS (I don't know why OMVF doesn't work with q35)
    • DO NOT START THE VM now, or it will hang, or even freeze the VM I don't know why
  • Set Display to none in options
  • Start the VM

Install NVIDIA drivers in VM

Inside the VM:

  1. apt install linux-headers-$(uname -r)
  2. add-apt-repository contrib
  3. apt install -y wget
  4. wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb
  5. dpkg -i cuda-keyring_1.1-1_all.deb
  6. apt update
  7. apt -V install nvidia-open (TODO: test compute-only drivers apt -V install nvidia-driver-cuda nvidia-kernel-open-dkms)
  8. Reboot
  9. Then check if it worked: nvidia-smi

Debrid CPU

The m720q limits its CPU power when a GPU is plugged. Without any configuration, when the GPU is sollicitated, the pc halts because of too much power to deliver to ensure no fire.

Warning

You need at least a 135 or 170 watts psu to put enough power in that tiny (beefy) pc.

Just disable BD Prochot (No BIOS changes, except the secure boot must be disabled, hoping a day I'll find how to get it enabled back).

On the host (not in VM):

apt-get install msr-tools
curl -LO https://raw.githubusercontent.com/fralapo/Disable-BD-PROCHOT-on-LINUX/main/Disable_BD_PROCHOT
chmod u+x Disable_BD_PROCHOT
./Disable_BD_PROCHOT

Limit the GPU power

Note

If you have soldering skills, you can instead change the 12K OCP resistor to 15-20K resistor, which basically makes overcurrent sensitivity less problematic, so you don't need anymore to limit the GPU power

The m720q only accept 50W max on the PCIe port, so we need to ensure not drawing more, or the system will halt without any notice!

This service makes:

  • Power draw limit at 50 watts (not enough, still have >12V spikes)
  • Limit GPU clocks at 1702 mhz and memory at max 6001 (seems very stable)
  1. List possible clock pairs: nvidia-smi --query-supported-clocks=mem,gr
  2. Select the best pair by using small clocks and increasing little by little using nvidia-smi -ac <mem clock>,<graphics clock>. 6001,1702 is pretty stable with RTX A2000 12GB
  3. Make the service: nano /etc/systemd/system/nvidia-power-limit.service:
[Unit]
Description=NVIDIA power limitation
Wants=syslog.target
[Service]
Type=oneshot
ExecStartPre=/usr/bin/nvidia-smi -pl 50
ExecStart=/usr/bin/nvidia-smi -ac 6001,1702
[Install]
WantedBy=multi-user.target
  1. Enable the new service: systemctl enable nvidia-power-limit.service

How to check GPU stability

  • Check CPU:
  • Check GPU: watch -n 1 'nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,utilization.memory,power.draw.instant,clocks.video,clocks.gr,clocks.sm,clocks.mem --format=csv'

Configure Docker

Inside the VM:

  1. apt install nvidia-container-toolkit
  2. nvidia-ctk runtime configure --runtime=docker
  3. systemctl restart docker.service
  4. This should show your GPU: docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi

Credits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment