{"record":{"id":"84f714cc967ef56f","repo":"LykosAI/StabilityMatrix","slug":"torch-was-not-installed-after-windows-rocm-setup","errorCode":null,"errorMessage":"torch was not installed after Windows ROCm setup.","messagePattern":"torch was not installed after Windows ROCm setup\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs","lineNumber":431,"sourceCode":"            .Select(gpu => WindowsRocmSupport.TryGetCanonicalArchitecture(gpu.GetAmdGfxArch()))\n            .FirstOrDefault(WindowsRocmSupport.IsSupportedArchitecture);\n    }\n\n    /// <summary>\n    /// Verifies that the installed torch build still reports usable ROCm metadata after helper-managed installs complete.\n    /// </summary>\n    private static async Task VerifyWindowsNativeTorchInstallAsync(\n        IPyVenvRunner venvRunner,\n        Action<ProcessOutput>? onConsoleOutput,\n        CancellationToken cancellationToken\n    )\n    {\n        cancellationToken.ThrowIfCancellationRequested();\n\n        var torchInfo = await venvRunner.PipShow(\"torch\").ConfigureAwait(false);\n        if (torchInfo is null)\n        {\n            throw new InvalidOperationException(\"torch was not installed after Windows ROCm setup.\");\n        }\n\n        var verificationResult = await venvRunner\n            .Run(\n                \"-c \\\"import json, torch; print(json.dumps({'version': torch.__version__, 'hip': torch.version.hip, 'cuda': torch.cuda.is_available()}))\\\"\"\n            )\n            .ConfigureAwait(false);\n\n        var verificationOutput = (verificationResult.StandardOutput ?? string.Empty).Trim();\n        if (string.IsNullOrWhiteSpace(verificationOutput))\n        {\n            throw new InvalidOperationException(\"Torch verification produced no output.\");\n        }\n\n        var verificationJson = TryExtractJsonObject(verificationOutput);\n        if (string.IsNullOrWhiteSpace(verificationJson))\n        {\n            throw new InvalidOperationException(","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs#L413-L449","documentation":"VerifyWindowsNativeTorchInstallAsync runs after the Windows ROCm torch setup completes and re-checks with pip show torch that the package actually landed. If torch is still absent (PipShow returns null), it throws InvalidOperationException - meaning the install command exited without error (or its failure was not fatal) but no torch distribution is present in the venv.","triggerScenarios":"The pip install of the ROCm torch wheel silently failed or installed into a different environment/venv; the index returned no wheel so pip was a no-op; disk full or antivirus quarantined the install; the venvRunner environment changed between install and verification.","commonSituations":"ROCm wheel unavailable for the arch so pip resolved nothing; proxy blocking downloads but pip returning non-fatal status; pip cache corruption; install commands run against system Python instead of the target venv.","solutions":["Re-run the install with pip output captured and check for errors (index unreachable, no matching wheel, resolution conflicts)","Verify the venvRunner points at the same venv for both install and verify steps","Check disk space and that antivirus/security software is not blocking the wheel install","Retry InstallWindowsNativeTorchAsync after clearing pip cache (pip cache purge) if the download failed silently"],"exampleFix":"// before\nawait InstallWindowsNativeTorchAsync(venvRunner, ...);\nawait VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); // fails\n// after\nvar result = await venvRunner.PipInstall(...);\nif (result.ExitCode != 0 || await venvRunner.PipShow(\"torch\") is null)\n{\n    logger.LogError(\"torch install failed: {Out}\", result.StandardOutput);\n    throw new ImageGenerationException(\"ROCm torch install failed\");\n}\nawait VerifyWindowsNativeTorchInstallAsync(venvRunner, ...);","handlingStrategy":"try-catch","validationCode":"if (await venvRunner.PipShow(\"torch\") is null)\n{\n    throw new InvalidOperationException(\"torch install did not take effect.\");\n}","typeGuard":null,"tryCatchPattern":"try { await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"was not installed\"))\n{\n    // re-run the install step with full pip logging, then verify again\n}","preventionTips":["Capture and check pip install exit codes and output rather than assuming success","Use the same venvRunner/venv for install and verification","Watch for silent failures: full disk, proxy blocks, antivirus interference"],"tags":["rocm","pip","torch","verification","windows"],"backgroundTag":"missing-dependency","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"}