Skip to content

Merged updates from Comfy-Org/comfy-aimdo#20 and Windows build chore#6

Closed
Apophis3158 wants to merge 20 commits intoasagi4:hack/rocm-supportfrom
Apophis3158:asagi4/rocm-support
Closed

Merged updates from Comfy-Org/comfy-aimdo#20 and Windows build chore#6
Apophis3158 wants to merge 20 commits intoasagi4:hack/rocm-supportfrom
Apophis3158:asagi4/rocm-support

Conversation

@Apophis3158
Copy link
Copy Markdown

@Apophis3158 Apophis3158 commented Mar 12, 2026

Tested on RX 9070 XT (gfx1201), Windows 10, torch 2.10.0+rocm7.12.0a20260304: example.py debug log

@Apophis3158 Apophis3158 changed the title Asagi4/rocm support Merged updates from Comfy-Org/comfy-aimdo and Windows chore Mar 12, 2026
@Apophis3158 Apophis3158 changed the title Merged updates from Comfy-Org/comfy-aimdo and Windows chore Merged updates from Comfy-Org/comfy-aimdo#20 and Windows chore Mar 12, 2026
Comment thread build-rocm-local_win.ps1 Outdated
Remove-Item -Recurse -Force $detoursDir
Write-Host "Build successful: comfy_aimdo\aimdo_rocm.dll"

# Copy amdhip64_7.dll to comfy_aimdo directory
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will try this PR locally - would be great if it works.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't try this yet, it seems specified 4 hooks working well because using _rocm_sdk_core, but Adrenalin one loaded first still used somewhere and will cause hang.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, we need to investigate further to ensure it doesn’t use the driver .dll at all.

@Apophis3158 Apophis3158 force-pushed the asagi4/rocm-support branch from 3dae483 to afbd5c1 Compare March 12, 2026 20:40
@Apophis3158 Apophis3158 changed the title Merged updates from Comfy-Org/comfy-aimdo#20 and Windows chore Merged updates from Comfy-Org/comfy-aimdo#20 and Windows load DLL from $env:VIRTUAL_ENV Mar 12, 2026
@Apophis3158
Copy link
Copy Markdown
Author

Apophis3158 commented Mar 12, 2026

Update: use _dupenv_s to get $env:VIRTUAL_ENV 626a7a6

❯ py .\examples\example.py  
HIP Library Path: C:\WINDOWS\SYSTEM32\amdhip64_7.dll
aimdo: src-win\cuda-detour.c:88:DEBUG:aimdo_setup_hooks: found VIRTUAL_ENV: H:\ROCm\ComfyUI\.venv
aimdo: src-win\cuda-detour.c:96:DEBUG:aimdo_setup_hooks: driver_dlls[0] = H:\ROCm\ComfyUI\.venv\Lib\site-packages\_rocm_sdk_core\bin\amdhip64.dll
aimdo: src-win\cuda-detour.c:96:DEBUG:aimdo_setup_hooks: driver_dlls[1] = H:\ROCm\ComfyUI\.venv\Lib\site-packages\_rocm_sdk_core\bin\amdhip64_7.dll
aimdo: src-win\cuda-detour.c:117:INFO:aimdo_setup_hooks: found driver at 00007FFAD7A40000, installing 4 hooks
aimdo: src-win\cuda-detour.c:70:DEBUG:install_hook_entrys: hooks successfully installed
aimdo: src\control.c:69:INFO:comfy-aimdo inited for GPU: AMD Radeon RX 9070 XT (VRAM: 16304 MB)

HIP Library Path: C:\WINDOWS\SYSTEM32\amdhip64_7.dll still shows up but don't worry, we actual using the _rocm_sdk_core one, because example running well (full log), if the Adrenalin one is used, system will hang.

@0xDELUXA
Copy link
Copy Markdown

0xDELUXA commented Mar 12, 2026

example.py works with C:\WINDOWS\SYSTEM32\amdhip64_7.dll too, but Comfy doesn't: Comfy-Org#2 (comment).
Have you tried it?

@Apophis3158
Copy link
Copy Markdown
Author

example.py works with C:\WINDOWS\SYSTEM32\amdhip64_7.dll too, but Comfy doesn't: Comfy-Org#2 (comment)

In my system running example.py with Adrenalin 26.2.2 C:\WINDOWS\SYSTEM32\amdhip64_7.dll always hang.

I'll try this test case later.

Comment thread src-win/cuda-detour.c Outdated
if ((ret < 0) || (ret >= BUFF_SIZE)) {
log(ERROR, "%s: Buffer overflow in snprintf\n", __func__);
} else {
log(DEBUG, "%s: driver_dlls[%d] = %s\n", __func__, i, driver_dlls[i]);
Copy link
Copy Markdown

@0xDELUXA 0xDELUXA Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prints:

aimdo: src-win\cuda-detour.c:96:DEBUG:aimdo_setup_hooks: driver_dlls[0] = C:\ComfyUI\venv\Lib\site-packages\_rocm_sdk_core\bin\amdhip64.dll
aimdo: src-win\cuda-detour.c:96:DEBUG:aimdo_setup_hooks: driver_dlls[1] = C:\ComfyUI\venv\Lib\site-packages\_rocm_sdk_core\bin\amdhip64_7.dll

The first file (_rocm_sdk_core\bin\amdhip64.dll) doesn't exist on my system, and presumably not on yours either - this print should be removed.
AMD renamed/versioned it - what used to be amdhip64.dll is now amdhip64_7.dll on current drivers. (AFAIK amdhip64.dll = ROCm 5, amdhip64_6.dll = ROCm 6)

Comment thread src-win/cuda-detour.c Outdated

ret = _dupenv_s(&venv, &buff_size, "VIRTUAL_ENV");
if ((ret == 0) && (venv != NULL)) {
log(DEBUG, "%s: found VIRTUAL_ENV: %s\n", __func__, venv);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't really add more debug logs - the console is already crowded enough, as the original NVIDIA Windows version already has three aimdo-related prints.

@Apophis3158 Apophis3158 force-pushed the asagi4/rocm-support branch from afbd5c1 to 965a63d Compare March 13, 2026 02:27
@Apophis3158
Copy link
Copy Markdown
Author

Apophis3158 commented Mar 13, 2026

@0xDELUXA after some further tests and looking up, I became frustrated with C:\WINDOWS\SYSTEM32\amdhip64_7.dll, loading it always cause system unstable, the only thing we can do is put _rocm_sdk_core one in package.

This PR only retains merge Comfy-Org#20 and Windows chore.

@Apophis3158 Apophis3158 changed the title Merged updates from Comfy-Org/comfy-aimdo#20 and Windows load DLL from $env:VIRTUAL_ENV Merged updates from Comfy-Org/comfy-aimdo#20 and Windows build chore Mar 13, 2026
@Apophis3158
Copy link
Copy Markdown
Author

Apophis3158 commented Mar 13, 2026

In some PR, setting PATH to dll will fix loading, but didn't work with me.
ROCm/TheRock#2019
ROCm/TheRock#3257
ggml-org/llama.cpp#17429 (comment) (use rocm-sdk path --bin or hipconfig --rocmpath)

And this print come out when torch is called first time, such as torch.cuda.current_device() in example.py or torch.cuda.is_available() from comfy_kitchen in ComfyUI. Maybe the right dll was loaded without print when aimdo not installed, then the wrong dll will be load with print when aimdo installed, but why?

@Apophis3158
Copy link
Copy Markdown
Author

@asagi4 please help test this merge on Linux.

@0xDELUXA
Copy link
Copy Markdown

In some PR, setting PATH to dll will fix loading, but didn't work with me.

Same here.

Maybe the right dll was loaded without print when aimdo not installed, then the wrong dll will be load with print when aimdo installed, but why?

Indeed. But why would that happen? That’s what I’d like to know too.

@0xDELUXA
Copy link
Copy Markdown

@0xDELUXA after some further tests and looking up, I became frustrated with C:\WINDOWS\SYSTEM32\amdhip64_7.dll, loading it always cause system unstable, the only thing we can do is put _rocm_sdk_core one in package.

This PR only retains merge Comfy-Org#20 and Windows chore.

So we stick with the manual copy approach then?

Comment thread build-rocm-local_win.ps1
# ── Compile ────────────────────────────────────────────────────────────────────
$sources = @(Get-Item "$root\src\*.c" -ErrorAction SilentlyContinue) + @(Get-Item "$root\src-win\*.c" -ErrorAction SilentlyContinue) | ForEach-Object { "`"$(F $_.FullName)`"" }
if (-not $sources) { throw "No .c source files found in src\ or src-win\." }
# use pure command to build: pwsh will handel *.c expanding and \ slash
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: handel should be handle.

Copy link
Copy Markdown

@0xDELUXA 0xDELUXA Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in PR #7 7abda54

@asagi4
Copy link
Copy Markdown
Owner

asagi4 commented Mar 13, 2026

I can take a look later. I don't mind keeping the support PR up to date with changes to master but since on Linux making aimdo work seems to depend entirely on AMD fixing HIP / rocr (unless someone can figure out a workaround), I'm not really actively working on it at the moment.

@0xDELUXA
Copy link
Copy Markdown

0xDELUXA commented Mar 13, 2026

Yeah, we ran into problems that we can't fix locally. AMD should look at the Linux side regarding the hipMemRelease issue, and the triton-windows devs should look at the Windows side regarding triton's CPU tensor? issue. We've opened issues and are waiting for any feedback.

@asagi4 asagi4 force-pushed the hack/rocm-support branch from bd6b9bf to 80ce863 Compare March 13, 2026 15:41
@asagi4
Copy link
Copy Markdown
Owner

asagi4 commented Mar 13, 2026

I merged this manually and dropped some of the type fixes and just downgraded the incompatible pointer type errors to warnings.

@asagi4 asagi4 closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants