Skip to content

Commit 4ed952d

Browse files
authored
Merge pull request #1158 from ionite34/backport/main/pr-1157
[dev to main] backport: Use recommended env vars for windows+rocm comfyUI (1157)
2 parents 4aa2625 + 265e67b commit 4ed952d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2
1111
- Changed ComfyUI torch index from `cu129` back to `cu128` for better compatibility with custom nodes
1212
- Updated SageAttention installer to install v2.2.0-windows.post3
1313
- Updated Nunchaku installer to install v1.0.1
14+
- Updated Windows ROCm ComfyUI installs to use recommended environment variables by default
1415
### Fixed
1516
- Fixed [#1372](https://github.com/LykosAI/StabilityMatrix/issues/1372), [#1399](https://github.com/LykosAI/StabilityMatrix/issues/1399) - LiteAsyncException upon starting Stability Matrix v2.15.0
1617
- Fixed [#1391](https://github.com/LykosAI/StabilityMatrix/issues/1391) - "Failed to parse" error when upgrading pip packages with extra index url

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.Json;
1+
using System.Collections.Immutable;
2+
using System.Text.Json;
23
using System.Text.RegularExpressions;
34
using Injectio.Attributes;
45
using NLog;
@@ -443,6 +444,8 @@ public override async Task RunPackage(
443444
await SetupVenv(installLocation, pythonVersion: PyVersion.Parse(installedPackage.PythonVersion))
444445
.ConfigureAwait(false);
445446

447+
VenvRunner.UpdateEnvironmentVariables(GetEnvVars);
448+
446449
VenvRunner.RunDetached(
447450
[Path.Combine(installLocation, options.Command ?? LaunchCommand), .. options.Arguments],
448451
HandleConsoleOutput,
@@ -808,4 +811,20 @@ private async Task InstallNunchaku(InstalledPackage? installedPackage)
808811
EventManager.Instance.OnPackageInstallProgressAdded(runner);
809812
await runner.ExecuteSteps([installNunchaku]).ConfigureAwait(false);
810813
}
814+
815+
private ImmutableDictionary<string, string> GetEnvVars(ImmutableDictionary<string, string> env)
816+
{
817+
// if we're not on windows or we don't have a windows rocm gpu, return original env
818+
var hasRocmGpu =
819+
SettingsManager.Settings.PreferredGpu?.IsWindowsRocmSupportedGpu()
820+
?? HardwareHelper.HasWindowsRocmSupportedGpu();
821+
822+
if (!Compat.IsWindows || !hasRocmGpu)
823+
return env;
824+
825+
// set some experimental speed improving env vars for Windows ROCm
826+
return env.SetItem("PYTORCH_TUNABLEOP_ENABLED", "1")
827+
.SetItem("MIOPEN_FIND_MODE", "2")
828+
.SetItem("TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL", "1");
829+
}
811830
}

0 commit comments

Comments
 (0)