From 7dc807784d55c8379385b00f10e5458f99adc9d4 Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 14 Oct 2023 12:14:08 -0700 Subject: [PATCH 1/4] Fix xformers install (#299) From df1a3ac7a99d7cd61fe60aedbfd1eb720204fcdc Mon Sep 17 00:00:00 2001 From: Ionite Date: Mon, 11 Mar 2024 17:05:08 -0400 Subject: [PATCH 2/4] Fix merge From 7a83c6ab60da6bfa7c14f02121d300d545bd6874 Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 26 Oct 2025 20:41:05 -0400 Subject: [PATCH 3/4] Fix VIRTUAL_ENV not set during ComfyUI-Zluda installation The install-sm.bat script requires VIRTUAL_ENV to be set for ZLUDA DLL patching to work correctly. Without this, the DLL copy commands fail silently, leaving original NVIDIA libraries unchanged and causing cublas errors during generation. This fix adds VIRTUAL_ENV=venv to the environment variables passed to the installation batch script. --- StabilityMatrix.Core/Models/Packages/ComfyZluda.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs b/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs index 72911e1d..9e83d09b 100644 --- a/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs +++ b/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs @@ -109,7 +109,7 @@ await newInstallBatPath [], installLocation, onConsoleOutput, - GetEnvVars(true) + GetEnvVars(true, installLocation) ); await installProcess.WaitForExitAsync(cancellationToken).ConfigureAwait(false); @@ -141,7 +141,7 @@ await SetupVenv(installLocation, pythonVersion: PyVersion.Parse(installedPackage args, installLocation, HandleConsoleOutput, - GetEnvVars(false) + GetEnvVars(false, installLocation) ); return; @@ -184,7 +184,7 @@ await zludaProcess GC.SuppressFinalize(this); } - private Dictionary GetEnvVars(bool isInstall) + private Dictionary GetEnvVars(bool isInstall, string installLocation) { var portableGitBin = new DirectoryPath(PrerequisiteHelper.GitBinPath); var hipPath = Path.Combine( @@ -202,6 +202,11 @@ private Dictionary GetEnvVars(bool isInstall) ["GIT"] = portableGitBin.JoinFile("git.exe"), }; + if (isInstall) + { + envVars["VIRTUAL_ENV"] = "venv"; + } + if (envVars.TryGetValue("PATH", out var pathValue)) { envVars["PATH"] = Compat.GetEnvPathWithExtensions(hipBinPath, portableGitBin, pathValue); From 9a0e51c6e33c4a14728db59e3eb644cc5ef3efd4 Mon Sep 17 00:00:00 2001 From: NeuralFault Date: Sun, 26 Oct 2025 21:15:19 -0400 Subject: [PATCH 4/4] Refactor: Use constant for venv directory and remove unused parameter - Added VenvDirectoryName constant for better maintainability - Removed unused installLocation parameter from GetEnvVars method - Tested: Build successful, fresh ComfyUI-Zluda install works, generation successful --- StabilityMatrix.Core/Models/Packages/ComfyZluda.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs b/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs index 9e83d09b..cb45b7a6 100644 --- a/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs +++ b/StabilityMatrix.Core/Models/Packages/ComfyZluda.cs @@ -27,6 +27,7 @@ IPyInstallationManager pyInstallationManager "https://github.com/lshqqytiger/ZLUDA/releases/download/rel.5e717459179dc272b7d7d23391f0fad66c7459cf/ZLUDA-nightly-windows-rocm6-amd64.zip"; private const string HipSdkExtensionDownloadUrl = "https://cdn.lykos.ai/HIP-SDK-extension.7z"; + private const string VenvDirectoryName = "venv"; private Process? zludaProcess; @@ -109,7 +110,7 @@ await newInstallBatPath [], installLocation, onConsoleOutput, - GetEnvVars(true, installLocation) + GetEnvVars(true) ); await installProcess.WaitForExitAsync(cancellationToken).ConfigureAwait(false); @@ -141,7 +142,7 @@ await SetupVenv(installLocation, pythonVersion: PyVersion.Parse(installedPackage args, installLocation, HandleConsoleOutput, - GetEnvVars(false, installLocation) + GetEnvVars(false) ); return; @@ -184,7 +185,7 @@ await zludaProcess GC.SuppressFinalize(this); } - private Dictionary GetEnvVars(bool isInstall, string installLocation) + private Dictionary GetEnvVars(bool isInstall) { var portableGitBin = new DirectoryPath(PrerequisiteHelper.GitBinPath); var hipPath = Path.Combine( @@ -204,7 +205,7 @@ private Dictionary GetEnvVars(bool isInstall, string installLoca if (isInstall) { - envVars["VIRTUAL_ENV"] = "venv"; + envVars["VIRTUAL_ENV"] = VenvDirectoryName; } if (envVars.TryGetValue("PATH", out var pathValue))