LykosAI/StabilityMatrix · error · InvalidOperationException

Torch verification produced no output.

Error message

Torch verification produced no output.

What it means

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.

Solutions

  1. Check the verificationResult.StandardError / ExitCode for the underlying python failure and fix that first (often a broken torch/ROCm DLL install)
  2. Run the same import snippet manually in the venv (python -c "import torch; print(torch.__version__)") to reproduce the failure
  3. Reinstall the ROCm torch build if importing torch fails (missing or mismatched ROCm dependencies)
  4. Verify the venvRunner resolves and executes python correctly (check python path and command quoting)

Example fix

// before
var verificationResult = await venvRunner.Run("-c \"import torch; ...\"");
// no stdout check
// after
var verificationResult = await venvRunner.Run("-c \"import torch; ...\"");
if (verificationResult.ExitCode != 0)
{
    throw new InvalidOperationException(
        $"torch verification failed: {verificationResult.StandardError}");
}
var verificationOutput = verificationResult.StandardOutput?.Trim();
Defensive patterns

Strategy: try-catch

Validate before calling

var result = await venvRunner.Run("-c \"import torch\"");
if (result.ExitCode != 0 || string.IsNullOrWhiteSpace(result.StandardOutput))
{
    // torch import broken; reinstall before verification
}

Try / catch

try { await VerifyWindowsNativeTorchInstallAsync(venvRunner, ...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("produced no output"))
{
    LogError("torch verification silent: stderr={Err}", result.StandardError);
    // reinstall the ROCm torch build
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12). Data as JSON: /api/errors/725bcf4e1e69535e. Report an issue: GitHub.

Appendix: source

Thrown at StabilityMatrix.Core/Services/Rocm/RocmPackageHelper.cs:443

    {
        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(
                $"Unexpected torch verification output: {verificationOutput}"
            );
        }

        JsonDocument verificationDocument;
        try
        {
            verificationDocument = JsonDocument.Parse(verificationJson);
        }
        catch (Exception exception)
        {
            throw new InvalidOperationException(

View on GitHub (pinned to af93d6ef57)