Skip to content

Commit 7fe8391

Browse files
authored
Merge branch 'main' into clean-main
2 parents d332aa1 + 4516c34 commit 7fe8391

File tree

4 files changed

+126
-7
lines changed

4 files changed

+126
-7
lines changed

StabilityMatrix.Avalonia/ViewModels/Dialogs/UpdateViewModel.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,68 @@ await updateHelper.DownloadUpdate(
162162
);
163163
}
164164

165+
// Handle Linux AppImage update
166+
if (Compat.IsLinux && Environment.GetEnvironmentVariable("APPIMAGE") is { } appImage)
167+
{
168+
try
169+
{
170+
var updateScriptPath = UpdateHelper.UpdateFolder.JoinFile("update_script.sh").FullPath;
171+
var newAppImage = UpdateHelper.ExecutablePath.FullPath;
172+
173+
var scriptContent = """
174+
#!/bin/bash
175+
set -e
176+
177+
# Wait for the process to exit
178+
while kill -0 "$PID" 2>/dev/null; do
179+
sleep 0.5
180+
done
181+
182+
# Move the new AppImage over the old one
183+
mv -f "$NEW_APPIMAGE" "$OLD_APPIMAGE"
184+
chmod +x "$OLD_APPIMAGE"
185+
186+
# Launch the new AppImage detached
187+
"$OLD_APPIMAGE" > /dev/null 2>&1 &
188+
disown
189+
""";
190+
await File.WriteAllTextAsync(updateScriptPath, scriptContent);
191+
192+
File.SetUnixFileMode(
193+
updateScriptPath,
194+
UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute
195+
);
196+
197+
var startInfo = new System.Diagnostics.ProcessStartInfo
198+
{
199+
FileName = "/usr/bin/env",
200+
Arguments = $"bash \"{updateScriptPath}\"",
201+
UseShellExecute = false,
202+
CreateNoWindow = true,
203+
};
204+
205+
startInfo.EnvironmentVariables["PID"] = Environment.ProcessId.ToString();
206+
startInfo.EnvironmentVariables["NEW_APPIMAGE"] = newAppImage;
207+
startInfo.EnvironmentVariables["OLD_APPIMAGE"] = appImage;
208+
209+
System.Diagnostics.Process.Start(startInfo);
210+
211+
App.Shutdown();
212+
return;
213+
}
214+
catch (Exception ex)
215+
{
216+
logger.LogError(ex, "Failed to execute AppImage update script");
217+
218+
var dialog = DialogHelper.CreateMarkdownDialog(
219+
"AppImage update script failed. \nCould not replace old AppImage with new version. Please check directory permissions. \nFalling back to standard update process. User intervention required: \nAfter program closes, \nplease move the new AppImage extracted in the '.StabilityMatrixUpdate' hidden directory to the old AppImage overwriting it. \n\nClose this dialog to continue with standard update process.",
220+
Resources.Label_UnexpectedErrorOccurred
221+
);
222+
223+
await dialog.ShowAsync();
224+
}
225+
}
226+
165227
// Set current version for update messages
166228
settingsManager.Transaction(
167229
s => s.UpdatingFromVersion = Compat.AppVersion,

StabilityMatrix.Core/Models/Packages/AiToolkit.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ IPyInstallationManager pyInstallationManager
3535
public override string LicenseUrl => "https://github.com/ostris/ai-toolkit/blob/main/LICENSE";
3636
public override string LaunchCommand => string.Empty;
3737

38-
public override Uri PreviewImageUri =>
39-
new(
40-
"https://camo.githubusercontent.com/ea35b399e0d659f9f2ee09cbedb58e1a3ec7a0eab763e8ae8d11d076aad5be40/68747470733a2f2f6f73747269732e636f6d2f77702d636f6e74656e742f75706c6f6164732f323032352f30322f746f6f6c6b69742d75692e6a7067"
41-
);
38+
public override Uri PreviewImageUri => new("https://cdn.lykos.ai/sm/packages/aitoolkit/preview.webp");
4239

4340
public override string OutputFolderName => "output";
4441
public override IEnumerable<TorchIndex> AvailableTorchIndices => [TorchIndex.Cuda];

StabilityMatrix.Core/Models/Packages/ComfyUI.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ await StandardPipInstallProcessAsync(
382382
var indexUrl = gfxArch switch
383383
{
384384
"gfx1151" => "https://rocm.nightlies.amd.com/v2/gfx1151",
385-
_ when gfxArch.StartsWith("gfx110") => "https://rocm.nightlies.amd.com/v2/gfx110X-dgpu",
385+
_ when gfxArch.StartsWith("gfx110") => "https://rocm.nightlies.amd.com/v2/gfx110X-all",
386386
_ when gfxArch.StartsWith("gfx120") => "https://rocm.nightlies.amd.com/v2/gfx120X-all",
387387
_ => throw new ArgumentOutOfRangeException(
388388
nameof(gfxArch),
@@ -870,6 +870,8 @@ private ImmutableDictionary<string, string> GetEnvVars(ImmutableDictionary<strin
870870
// set some experimental speed improving env vars for Windows ROCm
871871
return env.SetItem("PYTORCH_TUNABLEOP_ENABLED", "1")
872872
.SetItem("MIOPEN_FIND_MODE", "2")
873-
.SetItem("TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL", "1");
873+
.SetItem("TORCH_ROCM_AOTRITON_ENABLE_EXPERIMENTAL", "1")
874+
.SetItem("PYTORCH_ALLOC_CONF", "max_split_size_mb:6144,garbage_collection_threshold:0.8") // greatly helps prevent GPU OOM and instability/driver timeouts/OS hard locks and decreases dependency on Tiled VAE at standard res's
875+
.SetItem("COMFYUI_USE_MIOPEN", "1"); // re-enables "cudnn" in ComfyUI as it's needed for MiOpen to function properly
874876
}
875877
}

StabilityMatrix.Core/Models/Packages/ComfyZluda.cs

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using StabilityMatrix.Core.Helper;
77
using StabilityMatrix.Core.Helper.Cache;
88
using StabilityMatrix.Core.Helper.HardwareInfo;
9+
using StabilityMatrix.Core.Models;
910
using StabilityMatrix.Core.Models.FileInterfaces;
1011
using StabilityMatrix.Core.Models.Progress;
1112
using StabilityMatrix.Core.Processes;
@@ -40,8 +41,65 @@ IPyInstallationManager pyInstallationManager
4041
public override string Disclaimer =>
4142
"Prerequisite install may require admin privileges and a reboot. "
4243
+ "Visual Studio Build Tools for C++ Desktop Development will be installed automatically. "
43-
+ "AMD GPUs under the RX 6800 may require additional manual setup.";
44+
+ "AMD GPUs under the RX 6800 may require additional manual setup. ";
4445
public override string LaunchCommand => Path.Combine("zluda", "zluda.exe");
46+
47+
public override List<LaunchOptionDefinition> LaunchOptions
48+
{
49+
get
50+
{
51+
var options = new List<LaunchOptionDefinition>
52+
{
53+
new()
54+
{
55+
Name = "Cross Attention Method",
56+
Type = LaunchOptionType.Bool,
57+
InitialValue = "--use-quad-cross-attention",
58+
Options =
59+
[
60+
"--use-split-cross-attention",
61+
"--use-quad-cross-attention",
62+
"--use-pytorch-cross-attention",
63+
"--use-sage-attention",
64+
],
65+
},
66+
new()
67+
{
68+
Name = "Disable Async Offload",
69+
Type = LaunchOptionType.Bool,
70+
InitialValue = true,
71+
Options = ["--disable-async-offload"],
72+
},
73+
new()
74+
{
75+
Name = "Disable Pinned Memory",
76+
Type = LaunchOptionType.Bool,
77+
InitialValue = true,
78+
Options = ["--disable-pinned-memory"],
79+
},
80+
new()
81+
{
82+
Name = "Disable Smart Memory",
83+
Type = LaunchOptionType.Bool,
84+
InitialValue = false,
85+
Options = ["--disable-smart-memory"],
86+
},
87+
new()
88+
{
89+
Name = "Disable Model/Node Caching",
90+
Type = LaunchOptionType.Bool,
91+
InitialValue = false,
92+
Options = ["--cache-none"],
93+
},
94+
};
95+
96+
options.AddRange(
97+
base.LaunchOptions.Where(x => x.Name != "Cross Attention Method")
98+
);
99+
return options;
100+
}
101+
}
102+
45103
public override IEnumerable<TorchIndex> AvailableTorchIndices => [TorchIndex.Zluda];
46104

47105
public override TorchIndex GetRecommendedTorchVersion() => TorchIndex.Zluda;

0 commit comments

Comments
 (0)