{"record":{"id":"ecb113953b9e2388","repo":"LykosAI/StabilityMatrix","slug":"installed-torch-is-not-a-usable-windows-rocm-build-detected","errorCode":null,"errorMessage":"Installed torch is not a usable Windows ROCm build (detected version: {torchInfo.Version}).","messagePattern":"Installed torch is not a usable Windows ROCm build \\(detected version: (.+?)\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs","lineNumber":149,"sourceCode":"        CancellationToken cancellationToken = default\n    )\n    {\n        var state = machineState.Value;\n        var multiArchPythonPackageIndexUrl = WindowsRocmSupport.GetMultiArchPythonPackageIndexUrl(\n            state.RuntimeGfxArch\n        );\n\n        var torchInfo = await venvRunner.PipShow(\"torch\").ConfigureAwait(false);\n        if (torchInfo is null)\n        {\n            throw new InvalidOperationException(\n                \"torch is not installed in this environment. Install the Windows ROCm torch build first.\"\n            );\n        }\n\n        if (!IsUsableWindowsNativeTorchBuild(torchInfo.Version, null))\n        {\n            throw new InvalidOperationException(\n                $\"Installed torch is not a usable Windows ROCm build (detected version: {torchInfo.Version}).\"\n            );\n        }\n\n        var nightlyBuildDateToken = TryGetNightlyBuildDateToken(torchInfo.Version);\n        var installedRocmSdkDevel = await venvRunner.PipShow(RocmSdkDevelPackageName).ConfigureAwait(false);\n        if (\n            !string.IsNullOrWhiteSpace(nightlyBuildDateToken)\n            && HasNightlyBuildDateToken(installedRocmSdkDevel?.Version, nightlyBuildDateToken)\n        )\n        {\n            return;\n        }\n\n        var indexResult = await venvRunner\n            .PipIndex(RocmSdkDevelPackageName, multiArchPythonPackageIndexUrl)\n            .ConfigureAwait(false);\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs#L131-L167","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\n// venv has torch 2.4.0+cpu installed\nawait rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...);\n// after\nawait venvRunner.PipUninstall(\"torch\");\nawait rocmHelper.InstallWindowsNativeTorchAsync(venvRunner, ...); // installs ROCm wheel\nawait rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...);","handlingStrategy":"validation","validationCode":"var torchInfo = await venvRunner.PipShow(\"torch\");\nbool usable = torchInfo?.Version is string v &&\n    (v.Contains(\"rocm\", StringComparison.OrdinalIgnoreCase));\nif (!usable) { /* reinstall from the ROCm index before proceeding */ }","typeGuard":"bool IsRocmBuild(string? version) =>\n    !string.IsNullOrWhiteSpace(version) &&\n    version.Contains(\"rocm\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { await rocmHelper.EnsureWindowsSdkDevelAsync(venvRunner, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not a usable Windows ROCm build\"))\n{\n    await venvRunner.PipUninstall(\"torch\");\n    await rocmHelper.InstallWindowsNativeTorchAsync(venvRunner, ...);\n}","preventionTips":["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"],"tags":["rocm","torch","version-check","windows"],"backgroundTag":"incompatible-source-type","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}