Skip to content

Studio (Windows/ROCm): Smart App Control blocks the unsigned ROCm GPU libraries (rocfft.dll) -- "Bad Image" crash + failed install #6648

Closed

Description

@LeoBorcherding

Follow-up to #6588 / #6596 (Studio: lazy-import matplotlib so the server starts when the wheel is blocked).

Summary

On Windows 11 with Smart App Control (SAC) enabled, the pip-installed AMD ROCm runtime fails to load. import torch aborts with a modal "Bad Image" dialog:

...\_rocm_sdk_libraries_gfx120X_all\bin\rocfft.dll is either not designed to
run on Windows or it contains an error. ... Error status 0xc0e90002.

This now breaks two things:

  1. Runtime: any GPU code path that loads torch's ROCm libs fails to load (with a blocking "Bad Image" dialog), crashing the GPU path.
  2. Install: setup.ps1's post-install check (run by the installer) imports torch, which fails, so it reports Stale venv detected (torch could not be imported) and install.ps1 rolls the environment back. A correct ROCm install cannot complete.

Root cause

Smart App Control (and WDAC) enforce a kernel-level code-integrity policy that blocks unsigned DLLs from loading. The ROCm runtime shipped via pip (rocfft.dll, rocblas.dll, MIOpen.dll and friends, inside the _rocm_sdk_* wheels) is not code-signed, so SAC blocks it. The underlying error is OSError(winerror=4551), "An Application Control policy has blocked this file". The Windows CodeIntegrity event log confirms it: Event ID 3033/3077, policy {0283ac0f-...} VerifiedAndReputableDesktop, which is the SAC base policy.

Relationship to #6588 / #6596

#6596 fixed the first SAC-blocked wheel on the Studio boot path: matplotlib's compiled extension was imported at the top of core/training/training.py, so when SAC blocked it the whole server crashed at startup. Making it a lazy import let the server boot. rocfft is the next SAC wall: it is loaded later by torch on the first GPU op (torch has no rocfft of its own; it loads it from the _rocm_sdk wheels), so it only trips once you actually use the GPU. Same mechanism, deeper in the stack.

Why #6596 didn't surface this (SAC's verdict is time-varying)

Smart App Control's allow/block decision is not a fixed property of the file; it can change between boots. Evidence from this machine:

  • The CodeIntegrity log shows zero rocfft blocks until a reboot this week, after which the SAC policy was re-activated at boot and the blocks began.
  • The rocfft.dll is byte-identical before and after (same SHA-256, build date 2026-05-15), and the torch / rocm_sdk wheels (2.11.0+rocm7.13.0 / 7.13.0) are unchanged. Neither the binary nor the build changed.

When #6596 landed, the server booted past matplotlib and SAC was still allowing rocfft, so the GPU path worked. SAC later flipped its verdict on the same unsigned rocfft.dll and began blocking it. #6596 is correct and unrelated; this is a distinct, deeper instance of the same SAC mechanism, surfaced by a change in SAC's verdict rather than any code or binary change.

Environment

  • Windows 11, Smart App Control = On (registry VerifiedAndReputablePolicyState = 1)
  • AMD Radeon RX 9060 XT (gfx1200, RDNA4)
  • torch 2.11.0+rocm7.13.0, rocm_sdk 7.13.0, Python 3.13

What a fix can and cannot do

Nothing in user space can make a SAC-blocked unsigned DLL load. The only real resolutions are to turn Smart App Control off (Windows Security UI, which is irreversible) or to ship signed binaries. What Studio should do is fail gracefully rather than crash blind:

  1. Catch the load failure (winerror 4551) instead of letting it crash the process, and set the process error mode (SetErrorMode) to try to avoid the blocking "Bad Image" dialog (needs confirming that it suppresses this specific dialog).
  2. Detect SAC + the unsigned ROCm wheels and print one clear, actionable notice (what is happening and exactly how to turn SAC off), instead of a cryptic crash.
  3. Treat a code-integrity block (winerror 4551) as "GPU unavailable, fall back to CPU" rather than a fatal error. Right now setup.ps1's post-install torch-import check reads the block as "Stale venv detected (torch could not be imported)", fails setup, and install.ps1 rolls back a perfectly good environment. The block should be distinguished from a genuinely broken venv so the install completes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions