Browse Source

Merge branch 'dev' of https://github.com/ionite34/StabilityMatrix into show-package-install

pull/438/head
JT 10 months ago
parent
commit
72c8f264d7
  1. 4
      StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs
  2. 5
      StabilityMatrix.Avalonia/Helpers/WindowsPrerequisiteHelper.cs
  3. 3
      StabilityMatrix.Core/Helper/IPrerequisiteHelper.cs
  4. 3
      StabilityMatrix.Core/Helper/PrerequisiteHelper.cs
  5. 6
      StabilityMatrix.Core/Models/Packages/A3WebUI.cs
  6. 10
      StabilityMatrix.Core/Models/Packages/BasePackage.cs
  7. 8
      StabilityMatrix.Core/Models/Packages/InvokeAI.cs
  8. 16
      StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs
  9. 19
      StabilityMatrix.Core/Processes/ProcessRunner.cs

4
StabilityMatrix.Avalonia/Helpers/UnixPrerequisiteHelper.cs

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Versioning; using System.Runtime.Versioning;
@ -240,7 +241,8 @@ public class UnixPrerequisiteHelper : IPrerequisiteHelper
public async Task RunNpm( public async Task RunNpm(
ProcessArgs args, ProcessArgs args,
string? workingDirectory = null, string? workingDirectory = null,
Action<ProcessOutput>? onProcessOutput = null Action<ProcessOutput>? onProcessOutput = null,
IReadOnlyDictionary<string, string>? envVars = null
) )
{ {
var command = args.Prepend([NpmPath]); var command = args.Prepend([NpmPath]);

5
StabilityMatrix.Avalonia/Helpers/WindowsPrerequisiteHelper.cs

@ -115,11 +115,12 @@ public class WindowsPrerequisiteHelper : IPrerequisiteHelper
public async Task RunNpm( public async Task RunNpm(
ProcessArgs args, ProcessArgs args,
string? workingDirectory = null, string? workingDirectory = null,
Action<ProcessOutput>? onProcessOutput = null Action<ProcessOutput>? onProcessOutput = null,
IReadOnlyDictionary<string, string>? envVars = null
) )
{ {
var result = await ProcessRunner var result = await ProcessRunner
.GetProcessResultAsync(NodeExistsPath, args, workingDirectory) .GetProcessResultAsync(NodeExistsPath, args, workingDirectory, envVars)
.ConfigureAwait(false); .ConfigureAwait(false);
result.EnsureSuccessExitCode(); result.EnsureSuccessExitCode();

3
StabilityMatrix.Core/Helper/IPrerequisiteHelper.cs

@ -157,7 +157,8 @@ public interface IPrerequisiteHelper
Task RunNpm( Task RunNpm(
ProcessArgs args, ProcessArgs args,
string? workingDirectory = null, string? workingDirectory = null,
Action<ProcessOutput>? onProcessOutput = null Action<ProcessOutput>? onProcessOutput = null,
IReadOnlyDictionary<string, string>? envVars = null
); );
Task InstallNodeIfNecessary(IProgress<ProgressReport>? progress = null); Task InstallNodeIfNecessary(IProgress<ProgressReport>? progress = null);
} }

3
StabilityMatrix.Core/Helper/PrerequisiteHelper.cs

@ -112,7 +112,8 @@ public class PrerequisiteHelper : IPrerequisiteHelper
public Task RunNpm( public Task RunNpm(
ProcessArgs args, ProcessArgs args,
string? workingDirectory = null, string? workingDirectory = null,
Action<ProcessOutput>? onProcessOutput = null Action<ProcessOutput>? onProcessOutput = null,
IReadOnlyDictionary<string, string>? envVars = null
) )
{ {
throw new NotImplementedException(); throw new NotImplementedException();

6
StabilityMatrix.Core/Models/Packages/A3WebUI.cs

@ -148,7 +148,8 @@ public class A3WebUI(
Name = "No Half", Name = "No Half",
Type = LaunchOptionType.Bool, Type = LaunchOptionType.Bool,
Description = "Do not switch the model to 16-bit floats", Description = "Do not switch the model to 16-bit floats",
InitialValue = HardwareHelper.PreferRocm() || HardwareHelper.PreferDirectML(), InitialValue =
HardwareHelper.PreferRocm() || HardwareHelper.PreferDirectML() || Compat.IsMacOS,
Options = ["--no-half"] Options = ["--no-half"]
}, },
new() new()
@ -171,7 +172,7 @@ public class A3WebUI(
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None };
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps };
public override string MainBranch => "master"; public override string MainBranch => "master";
@ -208,6 +209,7 @@ public class A3WebUI(
TorchVersion.Cpu => "cpu", TorchVersion.Cpu => "cpu",
TorchVersion.Cuda => "cu121", TorchVersion.Cuda => "cu121",
TorchVersion.Rocm => "rocm5.6", TorchVersion.Rocm => "rocm5.6",
TorchVersion.Mps => "nightly/cpu",
_ => throw new ArgumentOutOfRangeException(nameof(torchVersion), torchVersion, null) _ => throw new ArgumentOutOfRangeException(nameof(torchVersion), torchVersion, null)
} }
) )

10
StabilityMatrix.Core/Models/Packages/BasePackage.cs

@ -201,10 +201,10 @@ public abstract class BasePackage
await venvRunner await venvRunner
.PipInstall( .PipInstall(
new PipInstallArgs() new PipInstallArgs()
.WithTorch("==2.0.1") .WithTorch("==2.1.2")
.WithTorchVision("==0.15.2") .WithTorchVision("==0.16.2")
.WithXFormers("==0.0.20") .WithXFormers("==0.0.23post1")
.WithTorchExtraIndex("cu118"), .WithTorchExtraIndex("cu121"),
onConsoleOutput onConsoleOutput
) )
.ConfigureAwait(false); .ConfigureAwait(false);
@ -230,7 +230,7 @@ public abstract class BasePackage
progress?.Report(new ProgressReport(-1f, "Installing PyTorch for CPU", isIndeterminate: true)); progress?.Report(new ProgressReport(-1f, "Installing PyTorch for CPU", isIndeterminate: true));
return venvRunner.PipInstall( return venvRunner.PipInstall(
new PipInstallArgs().WithTorch("==2.0.1").WithTorchVision(), new PipInstallArgs().WithTorch("==2.1.2").WithTorchVision(),
onConsoleOutput onConsoleOutput
); );
} }

8
StabilityMatrix.Core/Models/Packages/InvokeAI.cs

@ -283,11 +283,15 @@ public class InvokeAI : BaseGitPackage
) )
{ {
await PrerequisiteHelper.InstallNodeIfNecessary(progress).ConfigureAwait(false); await PrerequisiteHelper.InstallNodeIfNecessary(progress).ConfigureAwait(false);
await PrerequisiteHelper.RunNpm(["i", "pnpm"], installLocation).ConfigureAwait(false); await PrerequisiteHelper
.RunNpm(["i", "pnpm"], installLocation, envVars: envVars)
.ConfigureAwait(false);
if (Compat.IsMacOS || Compat.IsLinux) if (Compat.IsMacOS || Compat.IsLinux)
{ {
await PrerequisiteHelper.RunNpm(["i", "vite"], installLocation).ConfigureAwait(false); await PrerequisiteHelper
.RunNpm(["i", "vite"], installLocation, envVars: envVars)
.ConfigureAwait(false);
} }
var pnpmPath = Path.Combine( var pnpmPath = Path.Combine(

16
StabilityMatrix.Core/Models/Packages/StableDiffusionUx.cs

@ -142,7 +142,8 @@ public class StableDiffusionUx(
Name = "No Half", Name = "No Half",
Type = LaunchOptionType.Bool, Type = LaunchOptionType.Bool,
Description = "Do not switch the model to 16-bit floats", Description = "Do not switch the model to 16-bit floats",
InitialValue = HardwareHelper.PreferRocm() || HardwareHelper.PreferDirectML(), InitialValue =
HardwareHelper.PreferRocm() || HardwareHelper.PreferDirectML() || Compat.IsMacOS,
Options = ["--no-half"] Options = ["--no-half"]
}, },
new() new()
@ -165,7 +166,7 @@ public class StableDiffusionUx(
new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None }; new[] { SharedFolderMethod.Symlink, SharedFolderMethod.None };
public override IEnumerable<TorchVersion> AvailableTorchVersions => public override IEnumerable<TorchVersion> AvailableTorchVersions =>
new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm }; new[] { TorchVersion.Cpu, TorchVersion.Cuda, TorchVersion.Rocm, TorchVersion.Mps };
public override string MainBranch => "master"; public override string MainBranch => "master";
@ -199,6 +200,17 @@ public class StableDiffusionUx(
case TorchVersion.Rocm: case TorchVersion.Rocm:
await InstallRocmTorch(venvRunner, progress, onConsoleOutput).ConfigureAwait(false); await InstallRocmTorch(venvRunner, progress, onConsoleOutput).ConfigureAwait(false);
break; break;
case TorchVersion.Mps:
await venvRunner
.PipInstall(
new PipInstallArgs()
.WithTorch("==2.1.2")
.WithTorchVision()
.WithTorchExtraIndex("nightly/cpu"),
onConsoleOutput
)
.ConfigureAwait(false);
break;
} }
// Install requirements file // Install requirements file

19
StabilityMatrix.Core/Processes/ProcessRunner.cs

@ -356,7 +356,11 @@ public static class ProcessRunner
return StartAnsiProcess(fileName, args, workingDirectory, outputDataReceived, environmentVariables); return StartAnsiProcess(fileName, args, workingDirectory, outputDataReceived, environmentVariables);
} }
public static async Task<ProcessResult> RunBashCommand(string command, string workingDirectory = "") public static async Task<ProcessResult> RunBashCommand(
string command,
string workingDirectory = "",
IReadOnlyDictionary<string, string>? environmentVariables = null
)
{ {
// Escape any single quotes in the command // Escape any single quotes in the command
var escapedCommand = command.Replace("\"", "\\\""); var escapedCommand = command.Replace("\"", "\\\"");
@ -372,6 +376,14 @@ public static class ProcessRunner
WorkingDirectory = workingDirectory, WorkingDirectory = workingDirectory,
}; };
if (environmentVariables != null)
{
foreach (var (key, value) in environmentVariables)
{
processInfo.EnvironmentVariables[key] = value;
}
}
using var process = new Process(); using var process = new Process();
process.StartInfo = processInfo; process.StartInfo = processInfo;
@ -396,12 +408,13 @@ public static class ProcessRunner
public static Task<ProcessResult> RunBashCommand( public static Task<ProcessResult> RunBashCommand(
IEnumerable<string> commands, IEnumerable<string> commands,
string workingDirectory = "" string workingDirectory = "",
IReadOnlyDictionary<string, string>? environmentVariables = null
) )
{ {
// Quote arguments containing spaces // Quote arguments containing spaces
var args = string.Join(" ", commands.Select(Quote)); var args = string.Join(" ", commands.Select(Quote));
return RunBashCommand(args, workingDirectory); return RunBashCommand(args, workingDirectory, environmentVariables);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save