diff --git a/.github/workflows/backends.yml b/.github/workflows/backends.yml index 41b2c96..44b75d3 100644 --- a/.github/workflows/backends.yml +++ b/.github/workflows/backends.yml @@ -270,6 +270,10 @@ jobs: id: pack run: | nuget pack ./Backends/StableDiffusion.NET.Backend.Cpu.nuspec -version ${{ github.event.inputs.version }} + nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec -version ${{ github.event.inputs.version }} + nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec -version ${{ github.event.inputs.version }} + nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec -version ${{ github.event.inputs.version }} + nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec -version ${{ github.event.inputs.version }} nuget pack ./Backends/StableDiffusion.NET.Backend.Cuda.nuspec -version ${{ github.event.inputs.version }} nuget pack ./Backends/StableDiffusion.NET.Backend.Rocm.nuspec -version ${{ github.event.inputs.version }} diff --git a/Backends/StableDiffusion.NET.Backend.Cuda.nuspec b/Backends/StableDiffusion.NET.Backend.Cuda.nuspec index c4405f3..08c3c63 100644 --- a/Backends/StableDiffusion.NET.Backend.Cuda.nuspec +++ b/Backends/StableDiffusion.NET.Backend.Cuda.nuspec @@ -13,20 +13,17 @@ Copyright © Darth Affe 2024 readme.md + + + + + + + - - - - - - - - - - diff --git a/Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec b/Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec new file mode 100644 index 0000000..af81315 --- /dev/null +++ b/Backends/StableDiffusion.NET.Backend.Cuda11.Linux.nuspec @@ -0,0 +1,28 @@ + + + + StableDiffusion.NET.Backend.Cuda11.Linux + $version$ + StableDiffusion.NET.Backend.Cuda11.Linux + Darth Affe & stable-diffusion.cpp Authors + false + MIT + sd_net_cuda.png + https://github.com/DarthAffe/StableDiffusion.NET + CUDA 11 Linux Backend for StableDiffusion.NET. + + Copyright © Darth Affe 2024 + readme.md + + + + + + + + + + + + + diff --git a/Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec b/Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec new file mode 100644 index 0000000..1421635 --- /dev/null +++ b/Backends/StableDiffusion.NET.Backend.Cuda11.Windows.nuspec @@ -0,0 +1,28 @@ + + + + StableDiffusion.NET.Backend.Cuda11.Windows + $version$ + StableDiffusion.NET.Backend.Cuda11.Windows + Darth Affe & stable-diffusion.cpp Authors + false + MIT + sd_net_cuda.png + https://github.com/DarthAffe/StableDiffusion.NET + CUDA 11 Windows Backend for StableDiffusion.NET. + + Copyright © Darth Affe 2024 + readme.md + + + + + + + + + + + + + diff --git a/Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec b/Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec new file mode 100644 index 0000000..2ee03dc --- /dev/null +++ b/Backends/StableDiffusion.NET.Backend.Cuda12.Linux.nuspec @@ -0,0 +1,28 @@ + + + + StableDiffusion.NET.Backend.Cuda12.Linux + $version$ + StableDiffusion.NET.Backend.Cuda12.Linux + Darth Affe & stable-diffusion.cpp Authors + false + MIT + sd_net_cuda.png + https://github.com/DarthAffe/StableDiffusion.NET + CUDA 12 Linux Backend for StableDiffusion.NET. + + Copyright © Darth Affe 2024 + readme.md + + + + + + + + + + + + + diff --git a/Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec b/Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec new file mode 100644 index 0000000..8d89f5f --- /dev/null +++ b/Backends/StableDiffusion.NET.Backend.Cuda12.Windows.nuspec @@ -0,0 +1,28 @@ + + + + StableDiffusion.NET.Backend.Cuda12.Windows + $version$ + StableDiffusion.NET.Backend.Cuda12.Windows + Darth Affe & stable-diffusion.cpp Authors + false + MIT + sd_net_cuda.png + https://github.com/DarthAffe/StableDiffusion.NET + CUDA 12 Windows Backend for StableDiffusion.NET. + + Copyright © Darth Affe 2024 + readme.md + + + + + + + + + + + + + diff --git a/StableDiffusion.NET/Native/Native.Load.cs b/StableDiffusion.NET/Native/Native.Load.cs index 309d842..61ecb09 100644 --- a/StableDiffusion.NET/Native/Native.Load.cs +++ b/StableDiffusion.NET/Native/Native.Load.cs @@ -26,6 +26,18 @@ static Native() #region Methods + internal static bool LoadNativeLibrary(string libraryPath) + { + if (_loadedLibraryHandle != nint.Zero) return true; + if (NativeLibrary.TryLoad(libraryPath, out nint handle)) + { + _loadedLibraryHandle = handle; + return true; + } + + return false; + } + private static nint ResolveDllImport(string libraryname, Assembly assembly, DllImportSearchPath? searchpath) { if (libraryname != LIB_NAME) return nint.Zero; diff --git a/StableDiffusion.NET/StableDiffusionModel.cs b/StableDiffusion.NET/StableDiffusionModel.cs index a82c3b7..05be613 100644 --- a/StableDiffusion.NET/StableDiffusionModel.cs +++ b/StableDiffusion.NET/StableDiffusionModel.cs @@ -91,6 +91,15 @@ private void Initialize() } } + /// + /// Manually load the native stable diffusion library. + /// Once set, it will continue to be used for all instances. + /// + /// Path to the stable diffusion library. + /// Bool if the library loaded. + public static bool LoadNativeLibrary(string libraryPath) + => Native.LoadNativeLibrary(libraryPath); + public IImage TextToImage(string prompt, StableDiffusionParameter parameter) { ObjectDisposedException.ThrowIf(_disposed, this);