simoncaron.pve_nvidia_passthrough

Ansible Role: Proxmox VE NVIDIA Passthrough Configuration

=========

Ansible Lint Ansible Release Ansible Galaxy Downloads

This Ansible Role helps set up NVIDIA drivers on Proxmox VE 7.x so you can easily pass a GPU to virtual machines and LXC containers.

It has been tested on Proxmox VE 7.3 and works with LXC containers using the Ubuntu 22.04 template.

Requirements


There are no special requirements.

Role Variables


Here are the variables you can use, along with their default values (found in defaults/main.yml):

  • pve_nvidia_passthrough_driver_version: ""
  • pve_nvidia_passthrough_initramfs_update_options: -k all -u

You must provide a value for pve_nvidia_passthrough_driver_version, which should be the version of the NVIDIA driver you want to install. You can find the latest driver version for your GPU at NVIDIA's official site.

The pve_nvidia_passthrough_initramfs_update_options lets you set options for initializing the system when adding modules.

By default, this role installs and configures the driver for the Proxmox Host. If you want to install it for an LXC guest, set pve_nvidia_passthrough_install_mode to guest.

Dependencies


Before using this role on LXC guests, you need to adjust certain settings in your container’s .conf file.

For example, if you see the following entries in /dev:

root@pve01:/etc/pve/lxc# ls -l /dev/nvidia*
crw-rw-rw- 1 root root 195,   0 Feb 13 21:15 /dev/nvidia0
crw-rw-rw- 1 root root 195, 255 Feb 13 21:15 /dev/nvidiactl
crw-rw-rw- 1 root root 195, 254 Feb 13 21:15 /dev/nvidia-modeset
crw-rw-rw- 1 root root 511,   0 Feb 13 21:15 /dev/nvidia-uvm
crw-rw-rw- 1 root root 511,   1 Feb 13 21:15 /dev/nvidia-uvm-tools

You should add the following lines to the LXC guest .conf file (found at /etc/pve/lxc/.conf):

lxc.cgroup2.devices.allow: c 195:* rwm
lxc.cgroup2.devices.allow: c 508:* rwm
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file
lxc.mount.entry: dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file

After adding those lines, restart the LXC. You can run this role with pve_nvidia_passthrough_install_mode set to guest to configure the guest.

For more information, check out these resources:

Example Playbook


- hosts: localhost

  vars:
    pve_nvidia_passthrough_driver_version: "525.89.02"

  roles:
    - simoncaron.pve_nvidia_passthrough

License


MIT License

Author Information


This role was created by Simon Caron in 2023.

Informazioni sul progetto

A role to configure nvidia GPUs passthrough on Proxmox VE 7.x

Installa
ansible-galaxy install simoncaron.pve_nvidia_passthrough
Licenza
mit
Download
12.3k
Proprietario
Software Engineer | IaC | Containers | Ansible | Kubernetes | Helm