Skip to content

Commit

Permalink
Merge pull request LykosAI#344 from ionite34/always-update-torch
Browse files Browse the repository at this point in the history
Always update torch
  • Loading branch information
mohnjiles authored Nov 17, 2023
2 parents da399bc + d553069 commit ef2c3ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 59 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

[civitai]: https://civitai.com/

Multi-Platform Package Manager for Stable Diffusion
Multi-Platform Package Manager and Inference UI for Stable Diffusion

### ✨ New in 2.5 - [Inference](#inference), a built-in Stable Diffusion interface powered by ComfyUI
### ✨ New in 2.5 - [Inference](#inference-A-reimagined-built-in-Stable-Diffusion-experience), a built-in interface for Stable Diffusion powered by ComfyUI

### 🖱️ One click install and update for Stable Diffusion Web UI Packages
- Supports [Automatic 1111][auto1111], [Comfy UI][comfy], [SD.Next (Vladmandic)][sdnext], [VoltaML][voltaml], [InvokeAI][invokeai], [Fooocus][fooocus], and [Fooocus MRE][fooocus-mre]
Expand Down Expand Up @@ -107,6 +107,9 @@ Stability Matrix is now available in the following languages, thanks to our comm

If you would like to contribute a translation, please create an issue or contact us on Discord. Include an email where we'll send an invite to our [POEditor](https://poeditor.com/) project.

## Disclaimers
All trademarks, logos, and brand names are the property of their respective owners. All company, product and service names used in this document and licensed applications are for identification purposes only. Use of these names, trademarks, and brands does not imply endorsement.

## License

This repository maintains the latest source code release for Stability Matrix, and is licensed under the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html). Binaries and executable releases are licensed under the [End User License Agreement](https://lykos.ai/license).
83 changes: 26 additions & 57 deletions StabilityMatrix.Core/Models/Packages/InvokeAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,73 +188,42 @@ public override async Task InstallPackage(
var pipCommandArgs =
"-e . --use-pep517 --extra-index-url https://download.pytorch.org/whl/cpu";

var installTorch21 = versionOptions.IsLatest;

if (!string.IsNullOrWhiteSpace(versionOptions.VersionTag) && !versionOptions.IsLatest)
{
if (
Version.TryParse(versionOptions.VersionTag, out var version)
&& version >= new Version(3, 4)
)
{
installTorch21 = true;
}
}

switch (torchVersion)
{
// If has Nvidia Gpu, install CUDA version
case TorchVersion.Cuda:
if (installTorch21)
progress?.Report(
new ProgressReport(-1f, "Installing PyTorch for CUDA", isIndeterminate: true)
);

var args = new List<Argument>();
if (exists)
{
progress?.Report(
new ProgressReport(
-1f,
"Installing PyTorch for CUDA",
isIndeterminate: true
)
var pipPackages = await venvRunner.PipList().ConfigureAwait(false);
var hasCuda121 = pipPackages.Any(
p => p.Name == "torch" && p.Version.Contains("cu121")
);

var args = new List<Argument>();
if (exists)
if (!hasCuda121)
{
var pipPackages = await venvRunner.PipList().ConfigureAwait(false);
var hasCuda121 = pipPackages.Any(
p => p.Name == "torch" && p.Version.Contains("cu121")
);
if (!hasCuda121)
{
args.Add("--upgrade");
args.Add("--force-reinstall");
}
args.Add("--upgrade");
args.Add("--force-reinstall");
}

await venvRunner
.PipInstall(
new PipInstallArgs(
args.Any() ? args.ToArray() : Array.Empty<Argument>()
)
.WithTorch("==2.1.0")
.WithTorchVision("==0.16.0")
.WithXFormers("==0.0.22post7")
.WithTorchExtraIndex("cu121"),
onConsoleOutput
)
.ConfigureAwait(false);

Logger.Info("Starting InvokeAI install (CUDA)...");
pipCommandArgs =
"-e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121";
}
else
{
await InstallCudaTorch(venvRunner, progress, onConsoleOutput)
.ConfigureAwait(false);
Logger.Info("Starting InvokeAI install (CUDA)...");
pipCommandArgs =
"-e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu118";
}

await venvRunner
.PipInstall(
new PipInstallArgs(args.Any() ? args.ToArray() : Array.Empty<Argument>())
.WithTorch("==2.1.0")
.WithTorchVision("==0.16.0")
.WithXFormers("==0.0.22post7")
.WithTorchExtraIndex("cu121"),
onConsoleOutput
)
.ConfigureAwait(false);

Logger.Info("Starting InvokeAI install (CUDA)...");
pipCommandArgs =
"-e .[xformers] --use-pep517 --extra-index-url https://download.pytorch.org/whl/cu121";
break;
// For AMD, Install ROCm version
case TorchVersion.Rocm:
Expand Down

0 comments on commit ef2c3ab

Please sign in to comment.