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.
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.
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:
3. Identify the GPU to partition and enable GPU-P with:
4. Confirm partitioning is enabled:
Step 2. Assign GPU-P to the Linux VM
1. Stop the target Linux VM:
2. Assign the partitionable GPU to the VM:
3. Configure GPU resource allocation (optional):
4. Start the VM:
Step 3. Install GPU Drivers in Linux
Inside the Linux VM, install the appropriate drivers.
▶For NVIDIA GPUs, run: sudo apt update
Verify GPU availability:
▶For AMD GPUs, install Mesa drivers:
glxinfo | grep "OpenGL renderer"
Step 4. Test GPU Acceleration
Run a basic GPU benchmark to confirm acceleration:
For CUDA-capable NVIDIA GPUs, check CUDA support:
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.
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.
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.
Step 3. Click Start Backup and select Add the schedule and start backup now, or Add the schedule only.
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.