Jump to content

Single GPU Passthrough Shutdown VM problem

Go to solution Solved by Slo2025,

In Ubuntu 25.10 Single GPU Passthrough works without problems with RTX 5070 Ti.

 

Problem is Ubuntu 24.04 LTS and Shutdown VM not working.

 

Better to use latest Ubuntu version then Linux Mint.

Are you making a statement or asking a question?

 

Then use Ubuntu 25.10. Mint 22.2 is based on Ubuntu 24.04 LTS, there could be differences, particularly in the kernel. Perhaps try a mainline kernel at least.

Linux makes life better, breathes fresh life into older hardware and reduces e-waste. Adopt a penguin today! 🐧

OS of choice: Debian (server) | Gentoo (desktop/laptop) | Fedora (laptop)

Link to post
Share on other sites

Driver doesnt get assigned back to nvidia driver on the host after you assign it to vfio for pcie passthrough. You need to create some sort of hookscript to assign it back to host after you shutdown the vm. 

This existed ever since pci passthrough existed.

mY sYsTeM iS Not pErfoRmInG aS gOOd As I sAW oN yOuTuBe. WhA t IS a GoOd FaN CuRVe??!!? wHat aRe tEh GoOd OvERclok SeTTinGS FoR My CaRd??  HoW CaN I foRcE my GpU to uSe 1o0%? BuT WiLL i HaVE Bo0tllEnEcKs? RyZEN dOeS NoT peRfORm BetTer wItH HiGhER sPEED RaM!!dId i WiN teH SiLiCON LotTerrYyOu ShoUlD dEsHrOuD uR GPUmy SYstEm iS UNDerPerforMiNg iN WarzONEcan mY Pc Run WiNdOwS 11 ?woUld BaKInG MY GRaPHics card fIX it? MultimETeR TeSTiNG!! aMd'S GpU DrIvErS aRe as goOD aS NviDia's YOU SHoUlD oVERCloCk yOUR ramS To 5000C18! jellYfIn Client siDE TRanscoDinG

Link to post
Share on other sites

1 hour ago, Levent said:

Driver doesnt get assigned back to nvidia driver on the host after you assign it to vfio for pcie passthrough. You need to create some sort of hookscript to assign it back to host after you shutdown the vm. 

This existed ever since pci passthrough existed.

Yes this, or be lucky to have icpu instead.

Then you won't even need hook script.

I'm jank tinkerer if it works then it works.

Regardless of compatibility 🐧🖖

Link to post
Share on other sites

Indeed. But it's difficult to tell what the OP is trying to say or achieve. OP has been told a number of times in other threads that 'single GPU pass-through' is not possible if you want the host to also be using the same device for video output, w/o additional work to do the switch-over and have the host unload the driver and relinquish exclusive control of the device.

 

So perhaps this thread is about something else? Difficult to tell... If the assumption in this thread is that the switch-over seems to be happening automatically out of the box, then it's likely something distro-specific or software specific. Personally, I'm not aware of such functionality built into qemu and/or libvirt [yet].

Linux makes life better, breathes fresh life into older hardware and reduces e-waste. Adopt a penguin today! 🐧

OS of choice: Debian (server) | Gentoo (desktop/laptop) | Fedora (laptop)

Link to post
Share on other sites

28 minutes ago, NoLeafClover said:

'single GPU pass-through' is not possible

It is. GPU Passthrough in proxmox is basically this exact case, you create a perl script to load and unload drivers of your choice depending on actions. Pretty sure you can do that without proxmox too.

mY sYsTeM iS Not pErfoRmInG aS gOOd As I sAW oN yOuTuBe. WhA t IS a GoOd FaN CuRVe??!!? wHat aRe tEh GoOd OvERclok SeTTinGS FoR My CaRd??  HoW CaN I foRcE my GpU to uSe 1o0%? BuT WiLL i HaVE Bo0tllEnEcKs? RyZEN dOeS NoT peRfORm BetTer wItH HiGhER sPEED RaM!!dId i WiN teH SiLiCON LotTerrYyOu ShoUlD dEsHrOuD uR GPUmy SYstEm iS UNDerPerforMiNg iN WarzONEcan mY Pc Run WiNdOwS 11 ?woUld BaKInG MY GRaPHics card fIX it? MultimETeR TeSTiNG!! aMd'S GpU DrIvErS aRe as goOD aS NviDia's YOU SHoUlD oVERCloCk yOUR ramS To 5000C18! jellYfIn Client siDE TRanscoDinG

Link to post
Share on other sites

49 minutes ago, Levent said:

It is. GPU Passthrough in proxmox is basically this exact case, you create a perl script to load and unload drivers of your choice depending on actions. Pretty sure you can do that without proxmox too.

Please read what I wrote properly - don't be hasty. You have completely misread / misunderstood my comment and are misquoting it.

Linux makes life better, breathes fresh life into older hardware and reduces e-waste. Adopt a penguin today! 🐧

OS of choice: Debian (server) | Gentoo (desktop/laptop) | Fedora (laptop)

Link to post
Share on other sites

23 hours ago, Slo2025 said:

I'm using RTX 5070 Ti and Linux Mint 22.2. Problem is when i Shutdown VM computer doesn't go back to Linux and i need force turn off PC. I think problem is Linux Mint because in Ubuntu 25.10 works fine.

The problem is that your gpu is still hooked to the guest OS. You need to unhook it. You should have a script that attaches and reattaches your gpu and its drivers in libvirt or something like that. 

 

Checkout this video at this timestamp. I would just follow it since, it's pretty well made and complete.

 

 

Here is my hook script for booting and shutting down the vm:

 

DO NOT COPY IT, IT WILL VARY ESPECIALLY IF YOUR GPU IS DIFFERENT FOLLOW THE GUIDE ABOVE TO MAKE YOURS!!!

 

starting up:

#!/bin/bash
# Helpful for debugging
set -x

# Stop display manager
systemctl stop display-manager.service
# If you use GDM, you can also uncomment:
# killall gdm-x-session
sudo rmmod nvidia_drm
sudo rmmod nvidia_uvm
sudo rmmod nvidia_modeset
sudo rmmod nvidia

# Unbind VT consoles
echo 0 > /sys/class/vtconsole/vtcon0/bind
# Unbind EFI framebuffer
# echo efi-framebuffer.0 > /sys/bus/platform/drivers/efi-framebuffer/unbind

# Wait to avoid race conditions
sleep 2

# Unbind the GPU from the host driver
virsh nodedev-detach pci_0000_01_00_0   # GPU
virsh nodedev-detach pci_0000_01_00_1   # Audio function

# Load VFIO kernel module


shutting down vm:

 

#!/bin/bash
set -x

# Re-bind GPU to NVIDIA driver
virsh nodedev-reattach pci_0000_01_00_0   # GPU
virsh nodedev-reattach pci_0000_01_00_1   # Audio

# Reload NVIDIA modules
modprobe nvidia
modprobe nvidia_modeset
modprobe nvidia_uvm
modprobe nvidia_drm 

# Rebind VT consoles
echo 1 > /sys/class/vtconsole/vtcon0/bind
# echo 1 > /sys/class/vtconsole/vtcon1/bind

# Rebind EFI framebuffer
# echo "efi-framebuffer.0" > /sys/bus/platform/drivers/efi-framebuffer/bind

# Restart display manager
systemctl start display-manager.service

 

A lot of douches were telling me a while back that SGP wasn't possible but it indeed is. The only tradeoff is that your host system will be logged off and unsuable whilst the guestOS is on but, you might be able to rdp into your host from guest though, I am not so sure about that.

20 hours ago, NoLeafClover said:

Then use Ubuntu 25.10. Mint 22.2 is based on Ubuntu 24.04 LTS, there could be differences, particularly in the kernel. Perhaps try a mainline kernel at least.

This is wrong. The problem is with not having a hook script

 

16 hours ago, NoLeafClover said:

Indeed. But it's difficult to tell what the OP is trying to say or achieve. OP has been told a number of times in other threads that 'single GPU pass-through' is not possible if you want the host to also be using the same device for video output, w/o additional work to do the switch-over and have the host unload the driver and relinquish exclusive control of the device.

 

It is technically possible if your host runs a rdp server.

People on this forum say a lot of stuff without giving all the details, it's quite infuriating and misleading to say this.

 

Link to post
Share on other sites

 

6 minutes ago, g0ated said:

The problem is that your gpu is still hooked to the guest OS. You need to unhook it. You should have a script that attaches and reattaches your gpu and its drivers in libvirt or something like that. 

https://gitlab.com/risingprismtv/single-gpu-passthrough/-/wikis/7)-scripts-&-logfiles

 

I was using this Scripts.

Link to post
Share on other sites

1 minute ago, Slo2025 said:

Yeah I am not so sure about this, I edited my post check the video I included. 
Also, vBIOS rom dumping isn't necessary anymore. 

Link to post
Share on other sites

36 minutes ago, g0ated said:

You need to unhook it. You should have a script that attaches and reattaches your gpu and its drivers in libvirt or something like that.

This isn't strictly true, some of it can be done automagically; from `man virsh`:

Quote

      Passthrough  devices  cannot be simultaneously used by the host and its guest domains, nor by multiple
      active guests at once.  If the <hostdev> description of a  PCI  device  includes  the  attribute  man‐
      aged='yes', and the hypervisor driver supports it, then the device is in managed mode, and attempts to
      use  that  passthrough device in an active guest will automatically behave as if nodedev-detach (guest
      start, device hot-plug) and nodedev-reattach (guest stop, device hot-unplug) were called at the  right
      points.

 

Though, the time it takes for these things to happen makes me thing that for SGPU passthough, just effing reboot.

Link to post
Share on other sites

2 hours ago, Ralphred said:

This isn't strictly true, some of it can be done automagically; from `man virsh`:

 

Though, the time it takes for these things to happen makes me thing that for SGPU passthough, just effing reboot.

Yeah well it doesn’t in this case at least for me and there is no harm in doing it.

 

2 hours ago, Ralphred said:

Though, the time it takes for these things to happen makes me thing that for SGPU passthough, just effing reboot.

Doing sgp is way faster. I don’t like having to constantly reboot. 

Link to post
Share on other sites

9 hours ago, g0ated said:

This is wrong.

No, it's a perfectly reasonable hypothesis depending on the angle from which one is approaching the issue being presented in the original post. And here's why.

 

As I said, OP has previously asked about doing a single-GPU passthrough across multiple distros - people who follow this forum would be familiar - and was provided with the necessary information. The topic on SGP has been covered extensively on these forums, even in other threads - some "ChatGPT" style answers, but also a lot with working and useful solutions. OP has already previously had success with SGP with start/stop hooks. So, at this point, it's not unreasonable to assume that OP is familiar of how the process works.

 

Then, at least as far as I can read the original question, the issue presented the behaviour that OP is observing differs between Mint 22.2 and Ubuntu 25.10. The are perhaps a couple of obvious starting points:

  1. Issues with the hook(s), notably the shutdown one
  2. Differences between distros

Given OP's previous discussions of SGP and the claim that "it works on Ubuntu 25.10" it is not unreasonable to assume "equivalent configuration" was used under both distros, and without any additional details (1) can be discounted under these assumptions.

 

This leaves (2). Given Mint 22.2 is based on Ubuntu 24.04, there could be a number of factors due to regressions in the kernel or libvirt. I have done multi- and single-GPU (until ~2y ago) passthrough on VMs since it first became feasible and have encountered examples of both, especially a number years back when things were... rather more problematic. Granted, this is not the most likely cause.

 

Then another possibility is whether one or both of the distros may come these days with additional helpers out of the box that perform the necessary steps during startup and shutdown when the system's only GPU is configured as passthrough. I do not know the answer to that, as I don't use either of these disros, but it's a problem that should long have been addressed and, frankly, not that difficult to achieve for reasonable "out of the box" experience these days if maintainers had the desire to do so. But any regressions in such could also cause the described problem.

 

We can argue all day to what extent or depth any any assumptions should be listed - perhaps I should have done so - and equally why it's important to outline specific configuration details when presenting a problem to reduce, or ideally eliminate, anyone having to assume anything.

 

9 hours ago, g0ated said:

It is technically possible if your host runs a rdp server.

With both host and guest VM simultaneously using the GPU at the same time with full hardware acceleration? I would very much like to know the details of this, especially w/o something like the emerging [on some data centre / enterprise GPUs] support for SR-IOV. Or are we getting our wires crossed here [again]?

 

9 hours ago, g0ated said:

People on this forum say a lot of stuff without giving all the details, it's quite infuriating and misleading to say this.

Agree. One might also say it's equally infuriating when someone outright assumes other contributors have zero subject matter knowledge or experience w/o first establishing a common understanding. Not making accusations, just saying ...

Linux makes life better, breathes fresh life into older hardware and reduces e-waste. Adopt a penguin today! 🐧

OS of choice: Debian (server) | Gentoo (desktop/laptop) | Fedora (laptop)

Link to post
Share on other sites

2 hours ago, NoLeafClover said:

This leaves (2). Given Mint 22.2 is based on Ubuntu 24.04, there could be a number of factors due to regressions in the kernel or libvirt. I have done multi- and single-GPU (until ~2y ago) passthrough on VMs since it first became feasible and have encountered examples of both, especially a number years back when things were... rather more problematic. Granted, this is not the most likely cause.

Funny you say so because, I am using a sgp setup with windows being the guest on LM 22.2, and it works perfectly fine here. So, this isn't a distro issue. It's most likely a hook script/vm setup issue. The guide OP's using is also outdated and incorrect. 

 

2 hours ago, NoLeafClover said:

Agree. One might also say it's equally infuriating when someone outright assumes other contributors have zero subject matter knowledge or experience w/o first establishing a common understanding. Not making accusations, just saying ...

Just saying what? That I have zero subject matter experience on this? 

 

2 hours ago, NoLeafClover said:

With both host and guest VM simultaneously using the GPU at the same time with full hardware acceleration? I would very much like to know the details of this, especially w/o something like the emerging [on some data centre / enterprise GPUs] support for SR-IOV. Or are we getting our wires crossed here [again]?

 

I never said that. Don't put words in my mouth. HW acceleration while using the vm isn't possible, since the gpu belongs only to the vm at that point in time. 

Also you don't need hw acceleartion when using rdp and you shouldn't expect that. This is only a convenience thing.

 

My solution is by installing xrdp on the linux host and connecting to the linux host from the windows guest via mstc.exe. I haven't tested this though, there is not reason it shouldn't work. 

 

 

Learn to be less condescending and terse. Did you wake up on the wrong side of the bed today?

Link to post
Share on other sites

1 hour ago, g0ated said:

Funny you say so because, I am using a sgp setup with windows being the guest on LM 22.2, and it works perfectly fine here. So, this isn't a distro issue. It's most likely a hook script/vm setup issue. The guide OP's using is also outdated and incorrect. 

I never said it was definitively a distro issue, rather that it could be based on the assumption that OP had previously had things running on a different distro and most certainly having personally experienced differences in behaviour. A few years ago I had a case of regression in the downstream libvirt package where the permissions for "/etc/libvirt/hooks" were [wrongly] changed and hooks did not run. But they did on a system with different host distro. After some investigation, reverting the package to the previous version resolved the issue. Equally, I've had cases of system hangs and kernel panics on VM shutdown, and sometimes even at boot, due to kernel regressions.

 

Again, not sure why this is even being questioned - it's reasonable angle of looking at the problem given the little detail provided in the initial post. Perhaps it's more pragmatic to look at the hooks first - I already covered my rationale in the previous post, so no point in repeating it. Re the guide that the OP followed - this became apparent later in the thread, so it's completely irrelevant to the argument 🤷‍♂️

 

1 hour ago, g0ated said:

I never said that. Don't put words in my mouth.

I never said you did - it was, in fact, a genuine question. Because if it were, then I would have loved to know the details. I even explicitly asked if it's a case of misunderstanding what you were saying.

 

1 hour ago, g0ated said:

HW acceleration while using the vm isn't possible, since the gpu belongs only to the vm at that point in time. 

Also you don't need hw acceleartion when using rdp and you shouldn't expect that. This is only a convenience thing.

 

My solution is by installing xrdp on the linux host and connecting to the linux host from the windows guest via mstc.exe. I haven't tested this though, there is not reason it shouldn't work.

And this is my experience and understanding as well - there is no disagreement here. Hence why I posed the question re what you were suggesting with RDP, as I would have been very curious how it fits into the picture - the exact set-up you were referring to was not obvious [to me]. I thought you were referring to a more idealistic scenario where both host and guest could make simultaneous use of the GPU.  But looks like we're on the same page here, and what you are [now] describing makes perfect sense.

 

1 hour ago, g0ated said:

Just saying what? That I have zero subject matter experience on this? 

Not at all, quite the opposite - that it appeared to me your earlier post seemed to assume so. And it was in fact that post that came across, from my perspective, somewhat presumptuous and a bit condescending, not least because of your choice of wording. The reason I explicitly said I'm not necessarily making accusations is precisely because it's not always obvious to read intention in text format, so I wanted to make it clear that it could also be a case of misapprehension.

 

1 hour ago, g0ated said:

Learn to be less condescending and terse.

I don't think I ever was, and if that's how you perceived it then this was never the intention. It could be a case of misapprehension on your part. Perhaps on both our parts. Take that as you wish. But there's no point going in circles here pointing fingers at each other, it's a complete waste of everybody's time.

Linux makes life better, breathes fresh life into older hardware and reduces e-waste. Adopt a penguin today! 🐧

OS of choice: Debian (server) | Gentoo (desktop/laptop) | Fedora (laptop)

Link to post
Share on other sites

  • 4 weeks later...

Shutdown VM not working in Linux Mint because 1024x768 Resolution without NVIDIA Drivers and because this No Signal on Monitor when Shutdown VM.

 

I need to try Single GPU Passthrough in EndeavourOS.

 

In EndeavourOS i have 2560x1440 Resolution without NVIDIA Drivers.

 

Linux Mint 23 will support my GPU (Ubuntu 26.04 LTS Based).

 

My GPU (RTX 5070 Ti) is supported in Ubuntu 25.10 and newer.

Link to post
Share on other sites

20 minutes ago, Slo2025 said:

Shutdown VM not working in Linux Mint because 1024x768 Resolution without NVIDIA Drivers and because this No Signal on Monitor when Shutdown VM.

What stopping you from installing latest supported driver? 

| Intel i7-3770@4.2Ghz | Asus Z77-V | Zotac 980 Ti Amp! Omega | DDR3 1800mhz 4GB x4 | 300GB Intel DC S3500 SSD | 512GB Plextor M5 Pro | 2x 1TB WD Blue HDD |
 | Enermax NAXN82+ 650W 80Plus Bronze | Fiio E07K | Grado SR80i | Cooler Master XB HAF EVO | Logitech G27 | Logitech G600 | CM Storm Quickfire TK | DualShock 4 |

Link to post
Share on other sites

1 hour ago, xAcid9 said:

What stopping you from installing latest supported driver? 

 

Single GPU Passthrough doesn't work if NVIDIA Drivers is installed. In Classic GPU Passthrough (iGPU - Linux (Host), NVIDIA - Windows 11 (Guest)) you can install NVIDIA Drivers and set Default GPU in BIOS. Because this i do Single GPU Passthrough.

Link to post
Share on other sites

On 11/23/2025 at 6:24 AM, g0ated said:

The problem is that your gpu is still hooked to the guest OS. You need to unhook it.

 

Hooks was not problem.

 

https://www.reddit.com/r/VFIO/comments/p3n5hc/my_single_gpu_passthrough_guide_for_nvidia_users/

 

https://github.com/ilayna/Single-GPU-passthrough-amd-nvidia

 

 

THE EASIEST Single GPU Passthrough. You only need to run ./setup.sh and ./install_hooks.sh  .

 

I tried in Linux Mint 22.3 Beta. Shutdown VM not working (Linux freeze) because RTX 5070 Ti or Linux Mint.

 

 

 

https://github.com/NVIDIA/open-gpu-kernel-modules/issues/853

 

Describe the bug

I want to pass the 5070 Ti into a VM for local LLM purpose.
However, the GPU does not reset properly when the VM shuts down, and freezes/crashes the host.

 

Shutdown the VM. The VM cannot shutdown properly and eventually your PC will freeze or force reboot.

 

Link to post
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×