LykosAI/StabilityMatrix · error · InvalidOperationException
torch was not installed after Windows ROCm setup.
Error message
torch was not installed after Windows ROCm setup.
What it means
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.
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
Example fix
// before
await InstallWindowsNativeTorchAsync(venvRunner, ...);
await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); // fails
// after
var result = await venvRunner.PipInstall(...);
if (result.ExitCode != 0 || await venvRunner.PipShow("torch") is null)
{
logger.LogError("torch install failed: {Out}", result.StandardOutput);
throw new ImageGenerationException("ROCm torch install failed");
}
await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); Defensive patterns
Strategy: try-catch
Validate before calling
if (await venvRunner.PipShow("torch") is null)
{
throw new InvalidOperationException("torch install did not take effect.");
} Try / catch
try { await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("was not installed"))
{
// re-run the install step with full pip logging, then verify again
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Torch verification produced no output.
- torch is not installed in this environment. Install the…
- Installed torch is not a usable Windows ROCm build
- Unexpected torch verification output
- Installed torch is not a usable ROCm build. Verification…
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/84f714cc967ef56f.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs:431
.Select(gpu => WindowsRocmSupport.TryGetCanonicalArchitecture(gpu.GetAmdGfxArch()))
.FirstOrDefault(WindowsRocmSupport.IsSupportedArchitecture);
}
/// <summary>
/// Verifies that the installed torch build still reports usable ROCm metadata after helper-managed installs complete.
/// </summary>
private static async Task VerifyWindowsNativeTorchInstallAsync(
IPyVenvRunner venvRunner,
Action<ProcessOutput>? onConsoleOutput,
CancellationToken cancellationToken
)
{
cancellationToken.ThrowIfCancellationRequested();
var torchInfo = await venvRunner.PipShow("torch").ConfigureAwait(false);
if (torchInfo is null)
{
throw new InvalidOperationException("torch was not installed after Windows ROCm setup.");
}
var verificationResult = await venvRunner
.Run(
"-c \"import json, torch; print(json.dumps({'version': torch.__version__, 'hip': torch.version.hip, 'cuda': torch.cuda.is_available()}))\""
)
.ConfigureAwait(false);
var verificationOutput = (verificationResult.StandardOutput ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(verificationOutput))
{
throw new InvalidOperationException("Torch verification produced no output.");
}
var verificationJson = TryExtractJsonObject(verificationOutput);
if (string.IsNullOrWhiteSpace(verificationJson))
{
throw new InvalidOperationException(View on GitHub (pinned to af93d6ef57)