LykosAI/StabilityMatrix · error · InvalidOperationException
Installed torch is not a usable Windows ROCm build
Error message
Installed torch is not a usable Windows ROCm build (detected version: {torchInfo.Version}). What it means
EnsureWindowsSdkDevelAsync checks the installed torch version via IsUsableWindowsNativeTorchBuild, which requires the version string to indicate a ROCm build (contains 'rocm') or report a hip version. If the installed torch is a CPU or CUDA build (or has an unparseable version), the method throws InvalidOperationException with the detected version so the user knows the build is unusable for Windows ROCm.
Solutions
- Uninstall the existing torch (pip uninstall torch) and reinstall the Windows ROCm build from the AMD ROCm package index
- Run the helper's InstallWindowsNativeTorchAsync flow, which installs the correct ROCm-indexed wheel
- Check torch.__version__ in the venv - it should contain 'rocm' (e.g. 2.x.x.devYYYYMMDD+rocm...); if not, the wrong wheel is installed
- Ensure any pip constraints/extra-index-url entries are not pulling torch from PyPI instead of the ROCm index
Example fix
// before
// venv has torch 2.4.0+cpu installed
await rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...);
// after
await venvRunner.PipUninstall("torch");
await rocmHelper.InstallWindowsNativeTorchAsync(venvRunner, ...); // installs ROCm wheel
await rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...); Defensive patterns
Strategy: validation
Validate before calling
var torchInfo = await venvRunner.PipShow("torch");
bool usable = torchInfo?.Version is string v &&
(v.Contains("rocm", StringComparison.OrdinalIgnoreCase));
if (!usable) { /* reinstall from the ROCm index before proceeding */ } Type guard
bool IsRocmBuild(string? version) =>
!string.IsNullOrWhiteSpace(version) &&
version.Contains("rocm", StringComparison.OrdinalIgnoreCase); Try / catch
try { await rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("not a usable Windows ROCm build"))
{
await venvRunner.PipUninstall("torch");
await rocmHelper.InstallWindowsNativeTorchAsync(venvRunner, ...);
} Prevention
- Never pre-install torch from PyPI in ROCm venvs
- Install torch only from the AMD ROCm multi-arch index
- Check torch.__version__ contains 'rocm' after any manual pip operation
When it happens
Trigger: Calling EnsureWindowsSdkDevelAsync in a venv where torch is installed but is a CPU-only or CUDA Windows wheel (version string lacks 'rocm' and no hip metadata) - e.g. torch was installed from PyPI defaults instead of the ROCm index, or an earlier CUDA-based install was never replaced.
Common situations: User pre-installed torch with plain 'pip install torch' (CUDA/CPU wheel) before running ROCm setup; switched GPU vendor flows and reused an old environment; nightly ROCm wheel renamed so version no longer contains 'rocm'.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- Windows ROCm bitsandbytes is only supported on Python 3.12.x
- torch is not installed in this environment. Install the…
- torch was not installed after Windows ROCm setup.
- Torch verification produced no output.
- Unexpected torch verification output
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/ecb113953b9e2388.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs:149
CancellationToken cancellationToken = default
)
{
var state = machineState.Value;
var multiArchPythonPackageIndexUrl = WindowsRocmSupport.GetMultiArchPythonPackageIndexUrl(
state.RuntimeGfxArch
);
var torchInfo = await venvRunner.PipShow("torch").ConfigureAwait(false);
if (torchInfo is null)
{
throw new InvalidOperationException(
"torch is not installed in this environment. Install the Windows ROCm torch build first."
);
}
if (!IsUsableWindowsNativeTorchBuild(torchInfo.Version, null))
{
throw new InvalidOperationException(
$"Installed torch is not a usable Windows ROCm build (detected version: {torchInfo.Version})."
);
}
var nightlyBuildDateToken = TryGetNightlyBuildDateToken(torchInfo.Version);
var installedRocmSdkDevel = await venvRunner.PipShow(RocmSdkDevelPackageName).ConfigureAwait(false);
if (
!string.IsNullOrWhiteSpace(nightlyBuildDateToken)
&& HasNightlyBuildDateToken(installedRocmSdkDevel?.Version, nightlyBuildDateToken)
)
{
return;
}
var indexResult = await venvRunner
.PipIndex(RocmSdkDevelPackageName, multiArchPythonPackageIndexUrl)
.ConfigureAwait(false);
View on GitHub (pinned to af93d6ef57)