mirror of
https://github.com/Comfy-Org/comfy-aimdo.git
synced 2026-11-04 23:37:21 +00:00
[GH-ISSUE #21] vGPU windows can't use comfy-aimdo #6
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-aimdo#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AllentDan on GitHub (Mar 12, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-aimdo/issues/21
Hi, thanks for the great job. We've recently found that the latest ComfyUI can't work in vGPU windows!!! It turns out that there is
cuMemAddressReserveat https://github.com/Comfy-Org/comfy-aimdo/blob/v0.2.10/src/model-vbar.c#L199 . It means that all the cloud providers can't provide ComfyUI for windows Users. If possible, please consider using other cuda api to achieve the same result. cc @metebalci@rattus128 commented on GitHub (Mar 12, 2026):
What happens in your case?
After a bit of searching, im not reading any specific incompatibility regarding cuMemAddressReserve+vGPU.
@AllentDan commented on GitHub (Mar 16, 2026):
Well,I tried latest ComfyUI in both windows and ubuntu vGPU. In Windows, it was found that
cuMemAddressReserve. The test cuda demo is below:In Native Tools Command Prompt console, I used
nvcc -o test_cumemaddressreserve.exe test_cumemaddressreserve.c -lcudato compile the above codes. The execution result is below:@AllentDan commented on GitHub (Mar 16, 2026):
@rattus128 I consulted NVIDIA group, it was said that Windows vGPU can't open UVM.
@Aanerud commented on GitHub (Mar 16, 2026):
We have the same problem, and needs a way to ensure its disabled.
@Aanerud commented on GitHub (Mar 16, 2026):
Running into this on an NVIDIA L40S-48Q vGPU (SR-IOV / mediated device) on Proxmox VE. Plenty of VRAM available (47.7GB free), but the C-level call fails immediately:
The root cause is that vGPU guests have a limited virtual address space window exposed by the hypervisor.
vbar_allocate()tries to reservemodel_size * 10upfront as a contiguous VA reservation, which exceeds what the vGPU guest allows regardless of how much VRAM is actually free. This is not an OOM condition — it’s a VA space limitation specific to virtualised GPU environments.Workaround: Wrapping the
ModelVBARinstantiation inmodel_patcher.pywith atry/except MemoryErrorand falling back toNoneis sufficient, since the rest of the code already handlesvbar is Nonecorrectly (e.g.loaded_size()returns 0, etc.):With this patch ComfyUI runs fine on the vGPU — it just falls back to standard model management without VBAR optimisations, which is acceptable.
Would be great to have this handled gracefully upstream so vGPU users don’t need to patch
model_patcher.pymanually after everygit pull.@rattus128 commented on GitHub (Mar 16, 2026):
Thanks for the deep dive. Aimdo does have a clamp on the address space reservations to the total VRAM of the GPU:
https://github.com/Comfy-Org/comfy-aimdo/blob/master/src/model-vbar.c#L189
If you are still tripping up it means you must have a lot of models creating VBARs or the virtual address quota is extremely limited. Do you have much in the way of numbers?
On your setup if you just make 128GB VBARs in an infinate loop (should clamp to your VRAM with ^^), keep the refs and count them how far do you get?
We should get a sense of if your case is supportable with Aimdo and just look to detect and wholesale switch off depending on what the numbers are and how workable they are.
Core comfy has options and can free vbars more aggressively that it does to conserve VA space too.
@Aanerud commented on GitHub (Mar 17, 2026):
Thanks for the reply — based on your suggestions I did some more digging, this is what I found, looks like it may be an initialization order issue rather than VA space limits.
Setup: NVIDIA L40S-48Q (SR-IOV vGPU slice), driver 570.133.20, CUDA 12.8, Proxmox VE, Ubuntu 24.04.
When I called
init_device(0)directly I got this:So
init()succeeds and the.soloads fine, butinit_device()returnsFalse— which then leaves everything in a broken state downstream whenvbar_allocate()gets called.My best guess is that on vGPU the CUDA Driver API isn't available until PyTorch has first initialized the CUDA context. If aimdo's
init_device()fires before that happens it fails silently and never recovers. Doesn't seem to be a CUDA version thing — we're on 12.8 / driver 570 which is current.The workaround we implemented yesterday does the trick — a
try/except MemoryErroraround theModelVBARcall inmodel_patcher.pywhich falls back to standard model management cleanly — so we'll keep it as is for now.Happy to test anything on the vGPU setup if useful 👍
@rattus128 commented on GitHub (Mar 18, 2026):
If init_device returns false, comfy should completely disable the aimdo system:
You should be seeing that message at the bottom about "No working ..."
init_device() is already called after torch import for this reason. The sequence is:
init() # Aimdo need to exist before torch for the hook installation
import torch # Aimdo will catch and hook torch cuda load
init_device() # Aimdo sets it self up on the device etc with cuda fully accessible
Yeah im considering a universal fallback to handle your case. The problem is its hard to get it in the right place. There are corner cases with that approach as you mix DynamicVRAM file loader with the legacy ModelPatcher when you do it that way so you might have issues with some rarer models. You are probably ok with all the big name models.
@rattus128 commented on GitHub (Mar 18, 2026):
I have build a new wheel with some features that should help.
@Aanerud I have added a cuInit() which is the usual prescription for the bug you face. If we are lucky it switches everything on for you.
@AllentDan I have added a probe of the features aimdo need to init() so if they just outright fail, comfyUI will fall out of the dynamic VRAM mode completely.
Implementing Dynamic VRAM without the VMM features is possible but its not an overnighter and quite difficult. It wont reach the same memory performance as it will be quite a bit more complex and can fragment memory unless we fully implement caching allocators. Im happy for it to be a separate implementaiton of Aimdo, but we will keep with the VMM APIs when available so its very much a new feature level project.
Please try:
https://github.com/Comfy-Org/comfy-aimdo/actions/runs/23231132334
@AllentDan commented on GitHub (Mar 19, 2026):
Thanks for your reply @rattus128 . I will try the new wheel ASAP.
@Aanerud commented on GitHub (Mar 21, 2026):
Tested the new wheel — good progress! Here's what we're seeing:
What's working:
The async allocator is fully active and handling memory operations during inference — seeing lots of
pyt-cu-plug-alloc-asyncactivity in the logs. Prompt completed successfully (185 seconds, no crash).What's still failing:
cuMemAddressReservereturnsoperation not supportedon the vGPU, so VBAR/Dynamic VRAM still can't initialise:Summary:
The graceful fallback is working perfectly — ComfyUI no longer crashes, it just runs without Dynamic VRAM. The
cuMemAddressReserveAPI is simply not exposed by the vGPU driver to guest VMs, so VBAR will likely never work in this environment regardless of what we do on the software side. That's a hypervisor-level restriction.For our use case the fallback is totally fine — running smoothly on an L40S-48Q vGPU slice. Thanks for the quick turnaround on this! 👍