Detailed: Hyper-V GPU Partitioning Linux

GPU Partitioning (GPU-P) in Hyper-V offers several advantages for running Linux virtual machines with hardware-accelerated workloads. For example, efficient GPU resource sharing, improved cost-effectiveness, and simplified GPU management.

Amelia

By Amelia / Updated on March 21, 2025

Share this: instagram reddit

Microsoft Hyper-V is able to support GPU partitioning, enabling a virtual machine (VM) to access a portion of the physical GPU. It is useful for workloads that require hardware-accelerated graphics or AI/ML processing. In this article, we will look at how to use GPU partitioning on Linux VMs running on Hyper-V.

hyper v gpu partitioning linux

What is GPU Partitioning

GPU Partitioning allows multiple VMs to share a single physical GPU by allocating a fraction of its compute and memory resources. GPU Partitioning can offer:

  • Concurrent GPU sharing: Multiple VMs can utilize a single GPU simultaneously.
  • Better Resource Utilization: GPU-P dynamically allocates resources based on demand.
  • No VM Reboot Required: Changes can be applied without shutting down the VM.

How to Configure Hyper-V GPU Linux

Prerequisites

Before setting up GPU-P for a Linux VM, ensure you have configured the following:

  • A Windows 11 or Windows Server 2022 host with Hyper-V enabled.
  • A compatible GPU supporting GPU-P (e.g., NVIDIA GPUs with WDDM 2.9+ drivers).
  • A Linux distribution that supports GPU-P (Ubuntu 22.04 LTS, Debian, etc.)
  • The latest Hyper-V Integration Services are installed in the Linux VM.

Step 1. Enable GPU Partitioning on the Host

1. Open PowerShell as an administrator.

2. Run the following command to list available GPUs:

Get-VMPartitionableGpu

3. Identify the GPU to partition and enable GPU-P with:

Set-VMPartitionableGpu -InstanceId -Partitionable

4. Confirm partitioning is enabled:

Get-VMPartitionableGpu

Step 2. Assign GPU-P to the Linux VM

1. Stop the target Linux VM:

Stop-VM -Name "LinuxVM"

2. Assign the partitionable GPU to the VM:

Add-VMGpuPartitionAdapter -VMName "LinuxVM"

3. Configure GPU resource allocation (optional):

Set-VMGpuPartitionAdapter -VMName "LinuxVM" -MinPartitionVRAM 2048MB -MaxPartitionVRAM 4096MB

4. Start the VM:

Start-VM -Name "LinuxVM"

Step 3. Install GPU Drivers in Linux

Inside the Linux VM, install the appropriate drivers.

▶For NVIDIA GPUs, run: sudo apt update

sudo apt install -y nvidia-driver-535

Verify GPU availability:

nvidia-smi

▶For AMD GPUs, install Mesa drivers:

sudo apt install -y mesa-utils
glxinfo | grep "OpenGL renderer"

Step 4. Test GPU Acceleration

Run a basic GPU benchmark to confirm acceleration:

glmark2

For CUDA-capable NVIDIA GPUs, check CUDA support:

nvidia-smi
nvcc --version

Backup Hyper-V VMs to Avoid Data Loss

AOMEI Cyber Backup is a powerful backup solution designed to protect virtual machines (VMs) and physical machines. It is a free tool that allows you to protect the data of Windows Server and Hyper-V virtual machines, ensuring that you avoid irreversible data loss and prolonged downtime.

It offers comprehensive data protection, allows you to schedule automatic backups, easily restore data when needed, and manage backups with ease. Whether you're protecting a single server or multiple virtual machines, it provides the flexibility and security to keep critical data safe.

You can download the free AOMEI Cyber Backup now to enjoy more features.

Download FreewareVMware ESXi & Hyper-V
Secure Download

Simple steps to backup Hyper-V VMs

Step 1. Access to AOMEI Cyber Backup, navigate to Source Device > Hyper-V > + Add Hyper-V to add a Hyper-V host. And then click > Bind Device.

Add Hyper-V Host

Step 2. Navigate to Backup Task > + Create New Task, and then set Task Name, Backup Type, Device, Target, and Schedule.

  • Device: select VMs on the host in one backup task.
  • Target: Select to back up to a local path, or to a network path.
  • Schedule: choose to perform full and incremental backup, and automate execution according to the frequency you specified.

Schedule Hyper-V VM Backup

Step 3. Click Start Backup and select Add the schedule and start backup now, or Add the schedule only.

Start Backup

Conclusion

GPU partitioning in Hyper-V allows Linux VMs to utilize hardware-accelerated workloads without needing an entire GPU. While support for Linux is still evolving, GPU-P provides a cost-effective way to share GPU resources among multiple VMs efficiently.

Amelia
Amelia · Editor
Amelia is an editor from AOMEI. Trained in professional systems, she specializes in solving problems in enterprise databases, virtual machines, and physical environments. With a high sense of responsibility, she is dedicated to protecting business data and security.