{"record":{"id":"725bcf4e1e69535e","repo":"LykosAI/StabilityMatrix","slug":"torch-verification-produced-no-output","errorCode":null,"errorMessage":"Torch verification produced no output.","messagePattern":"Torch verification produced no output\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs","lineNumber":443,"sourceCode":"    {\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(\n                $\"Unexpected torch verification output: {verificationOutput}\"\n            );\n        }\n\n        JsonDocument verificationDocument;\n        try\n        {\n            verificationDocument = JsonDocument.Parse(verificationJson);\n        }\n        catch (Exception exception)\n        {\n            throw new InvalidOperationException(","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs#L425-L461","documentation":"VerifyWindowsNativeTorchInstallAsync runs a Python snippet that prints torch version/hip/cuda info as JSON. If the process produced no standard output at all (after trimming), it throws InvalidOperationException, because verification cannot proceed without the JSON payload. This usually means the embedded python -c command failed before printing (crash, import error, stderr-only output) or output capture failed.","triggerScenarios":"The verification run of venvRunner.Run(\"-c \\\"import json, torch; ...\\\"\") wrote nothing to stdout - e.g. torch import crashed (missing DLLs, broken ROCm install), python itself failed to start, or the process exited with an error writing only to stderr.","commonSituations":"Broken torch installation where importing torch throws (missing HIP/ROCm DLLs on Windows); the venv's python executable is corrupt; the command string quoting breaks under the runner so python never executes the print.","solutions":["Check the verificationResult.StandardError / ExitCode for the underlying python failure and fix that first (often a broken torch/ROCm DLL install)","Run the same import snippet manually in the venv (python -c \"import torch; print(torch.__version__)\") to reproduce the failure","Reinstall the ROCm torch build if importing torch fails (missing or mismatched ROCm dependencies)","Verify the venvRunner resolves and executes python correctly (check python path and command quoting)"],"exampleFix":"// before\nvar verificationResult = await venvRunner.Run(\"-c \\\"import torch; ...\\\"\");\n// no stdout check\n// after\nvar verificationResult = await venvRunner.Run(\"-c \\\"import torch; ...\\\"\");\nif (verificationResult.ExitCode != 0)\n{\n    throw new InvalidOperationException(\n        $\"torch verification failed: {verificationResult.StandardError}\");\n}\nvar verificationOutput = verificationResult.StandardOutput?.Trim();","handlingStrategy":"try-catch","validationCode":"var result = await venvRunner.Run(\"-c \\\"import torch\\\"\");\nif (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StandardOutput))\n{\n    // torch import broken; reinstall before verification\n}","typeGuard":null,"tryCatchPattern":"try { await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"produced no output\"))\n{\n    LogError(\"torch verification silent: stderr={Err}\", result.StandardError);\n    // reinstall the ROCm torch build\n}","preventionTips":["Always check ExitCode and StandardError alongside StandardOutput from venv runs","Test 'python -c \"import torch\"' manually after install to catch DLL/import breakage early","Verify venvRunner command quoting survives the runner's shell handling"],"tags":["rocm","torch","verification","python","windows"],"backgroundTag":"empty-response-body","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"}