LykosAI/StabilityMatrix · error · InvalidOperationException

No compatible torch version found in the virtual…

Error message

No compatible torch version found in the virtual environment.

What it means

InstallNunchakuStep maps the installed torch version (2.7–2.10) to a Nunchaku wheel tag; any other torch version hits the switch default and throws InvalidOperationException, since no prebuilt Nunchaku wheel exists for it.

Solutions

  1. Upgrade or downgrade torch in the venv to a supported release (2.7, 2.8, 2.9, or 2.10)
  2. Wait for/update to a Stability Matrix version supporting newer Nunchaku wheels
  3. Build Nunchaku from source against your torch version instead of using this install step

Example fix

// before
venv.PipInstall("torch"); // may install unsupported version
// after
venv.PipInstall("torch==2.8.0");
Defensive patterns

Strategy: validation

Validate before calling

var torch = await venv.GetPipPackageInfo("torch");
var supported = new[]{"2.7","2.8","2.9","2.10"};
if (torch is null || !supported.Any(p => torch.Version.StartsWith(p))) pinTorch(venv);

Try / catch

try { await step.ExecuteAsync(progress); } catch (InvalidOperationException ex) when (ex.Message.Contains("compatible torch")) { /* pin torch to 2.7-2.10 and retry */ }

Prevention

When it happens

Trigger: Running the Nunchaku install step with a venv containing torch < 2.7, > 2.10, or a dev/rc version not starting with those prefixes.

Common situations: Very new torch releases ahead of Nunchaku wheel publishing; old pinned torch from legacy packages; nightly torch builds.

Related errors


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

Appendix: source

Thrown at StabilityMatrix.Core/Models/PackageModification/InstallNunchakuStep.cs:69

            11 => "cp311",
            12 => "cp312",
            13 => "cp313",
            _ => throw new ArgumentOutOfRangeException("Invalid Python version"),
        };
        var platform = Compat.IsWindows ? "win_amd64" : "linux_x86_64";

        if (torchInfo is null)
        {
            throw new InvalidOperationException("Torch is not installed in the virtual environment.");
        }

        var torchVersion = torchInfo.Version switch
        {
            var v when v.StartsWith("2.7") => "2.7",
            var v when v.StartsWith("2.8") => "2.8",
            var v when v.StartsWith("2.9") => "2.9",
            var v when v.StartsWith("2.10") => "2.10",
            _ => throw new InvalidOperationException(
                "No compatible torch version found in the virtual environment."
            ),
        };

        var downloadUrl =
            $"https://github.com/nunchaku-tech/nunchaku/releases/download/v1.0.2/nunchaku-1.0.2+torch{torchVersion}-{shortPythonVersionString}-{shortPythonVersionString}-{platform}.whl";
        progress?.Report(
            new ProgressReport(-1f, message: "Installing Nunchaku backend", isIndeterminate: true)
        );

        await venvRunner.PipInstall(downloadUrl, progress.AsProcessOutputHandler()).ConfigureAwait(false);

        progress?.Report(
            new ProgressReport(1f, message: "Nunchaku backend installed successfully", isIndeterminate: false)
        );

        var extensions = await ComfyExtensionManager
            .GetManifestExtensionsAsync(ComfyExtensionManager.DefaultManifests)

View on GitHub (pinned to af93d6ef57)