{"record":{"id":"271b7844dcb0a879","repo":"LykosAI/StabilityMatrix","slug":"installed-torch-is-not-a-usable-rocm-build-verification","errorCode":null,"errorMessage":"Installed torch is not a usable ROCm build. Verification output: {verificationOutput}","messagePattern":"Installed torch is not a usable ROCm build\\. Verification output: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs","lineNumber":478,"sourceCode":"        {\n            throw new InvalidOperationException(\n                $\"Unexpected torch verification output: {verificationOutput}\",\n                exception\n            );\n        }\n\n        using (verificationDocument)\n        {\n            var root = verificationDocument.RootElement;\n            var version = root.TryGetProperty(\"version\", out var versionElement)\n                ? versionElement.GetString()\n                : null;\n            var hipVersion = root.TryGetProperty(\"hip\", out var hipElement) ? hipElement.GetString() : null;\n            var cudaAvailable = root.TryGetProperty(\"cuda\", out var cudaElement) && cudaElement.GetBoolean();\n\n            if (!IsUsableWindowsNativeTorchBuild(version, hipVersion))\n            {\n                throw new InvalidOperationException(\n                    $\"Installed torch is not a usable ROCm build. Verification output: {verificationOutput}\"\n                );\n            }\n\n            if (!cudaAvailable)\n            {\n                onConsoleOutput?.Invoke(\n                    ProcessOutput.FromStdErrLine(\n                        $\"Torch verification warning: installed ROCm torch build reported cuda={cudaAvailable}; continuing because ROCm metadata was detected (version={version}, hip={hipVersion}).\"\n                    )\n                );\n            }\n\n            onConsoleOutput?.Invoke(\n                ProcessOutput.FromStdOutLine(\n                    $\"Torch verification: version={version}, hip={hipVersion}, cuda={cudaAvailable}\"\n                )\n            );","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs#L460-L496","documentation":"The verification JSON parsed successfully, but IsUsableWindowsNativeTorchBuild rejected the version/hip combination — the installed torch is not a usable ROCm build (e.g. a CPU-only or CUDA torch got installed where a ROCm wheel was expected). The helper throws with the full verification output so the actual versions are visible.","triggerScenarios":"InstallWindowsNativeTorchAsync -> VerifyWindowsNativeTorchInstallAsync after pip installs the ROCm torch wheels, when the reported torch/torchvision versions fail IsUsableWindowsNativeTorchBuild (wrong version, missing '+rocm' build tag, or no hip version).","commonSituations":"pip resolved to a CPU or CUDA wheel because the ROCm index URL was wrong or unavailable; a cached wheel of the wrong variant was reused; the ROCm wheel index no longer hosts the pinned version; torch was upgraded afterwards by another tool, dropping the +rocm tag.","solutions":["Check the verification output in the message for the installed torch version and whether it carries a +rocm build tag and hip version.","Reinstall with the explicit ROCm wheel index (pip install torch --index-url https://download.pytorch.org/whl/rocm<ver>) so the ROCm build is actually selected.","Clear the pip cache or force --force-reinstall to avoid a stale CPU/CUDA wheel being reused.","Pin torchvision/torch versions compatible with the app's expected ROCm build and retry the install."],"exampleFix":"// before: pip resolved CPU wheel\npip install torch torchvision\n// after: force ROCm build from the ROCm index\npip install --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/rocm5.7","handlingStrategy":"validation","validationCode":"var (torch, hip) = await ProbeTorchAsync();\nif (!(torch?.EndsWith(\"+rocm\", StringComparison.OrdinalIgnoreCase) ?? false) || hip is null)\n    throw new InvalidOperationException($\"Torch is not a ROCm build: {torch}, hip={hip}\");","typeGuard":"static bool IsRocmBuild(string? version) =>\n    version?.Contains(\"+rocm\", StringComparison.OrdinalIgnoreCase) == true;","tryCatchPattern":"try { await helper.InstallWindowsNativeTorchAsync(...); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Installed torch is not a usable ROCm build\"))\n{\n    logger.Warning(ex, \"Non-ROCm torch installed; reinstalling from ROCm index\");\n    await ReinstallRocmTorchAsync();\n}","preventionTips":["Always install torch with the explicit ROCm wheel index URL.","Force reinstall to prevent cached CPU/CUDA wheels from being reused.","Verify the '+rocm' build tag and hip version after every torch upgrade.","Prevent other tools from silently upgrading torch to a non-ROCm build."],"tags":["rocm","torch","windows","version-mismatch"],"backgroundTag":"invalid-config-value","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"}