TensorStack-AI / OnnxStack

C# Stable Diffusion using ONNX Runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fails when loading model

yggdrasil75 opened this issue · comments

[1/5/2024 8:57:40 AM] [Information] [ModelPickerControl] [LoadModel] - 'dreamlike' Loaded., Elapsed: 3ms
[1/5/2024 8:57:43 AM] [Information] [ModelPickerControl] [LoadModel] - 'dreamlike' Loading...
[1/5/2024 8:57:43 AM] [Error] [ModelPickerControl] An error occured while loading model 'dreamlike'
Microsoft.ML.OnnxRuntime.OnnxRuntimeException: [ErrorCode:RuntimeException] D:\a_work\1\s\onnxruntime\core\session\provider_bridge_ort.cc:1193 onnxruntime::ProviderLibrary::Get [ONNXRuntimeError] : 1 : FAIL : LoadLibrary failed with error 126 "" when trying to load "C:\non-docker\OnnxStack_TensorRT\onnxruntime_providers_tensorrt.dll"

at Microsoft.ML.OnnxRuntime.SessionOptions.AppendExecutionProvider_Tensorrt(Int32 deviceId)
at OnnxStack.Core.Extensions.GetSessionOptions(OnnxModelConfig configuration)
at OnnxStack.Core.Model.OnnxModelSession..ctor(OnnxModelConfig configuration, PrePackedWeightsContainer container)
at OnnxStack.Core.Model.OnnxModelSet.<.ctor>b__3_1(OnnxModelConfig modelConfig)
at System.Collections.Immutable.ImmutableDictionary.<>c__DisplayClass9_03.<ToImmutableDictionary>b__0(TSource element) at System.Linq.Enumerable.SelectListIterator2.MoveNext()
at System.Collections.Immutable.ImmutableDictionary2.AddRange(IEnumerable1 items, MutationInput origin, KeyCollisionBehavior collisionBehavior)
at System.Collections.Immutable.ImmutableDictionary2.AddRange(IEnumerable1 pairs, Boolean avoidToHashMap)
at System.Collections.Immutable.ImmutableDictionary2.AddRange(IEnumerable1 pairs)
at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 keyComparer, IEqualityComparer1 valueComparer) at System.Collections.Immutable.ImmutableDictionary.ToImmutableDictionary[TSource,TKey,TValue](IEnumerable1 source, Func2 keySelector, Func2 elementSelector)
at OnnxStack.Core.Model.OnnxModelSet..ctor(IOnnxModelSetConfig configuration)
at OnnxStack.Core.Services.OnnxModelService.LoadModelSet(IOnnxModelSetConfig modelSetConfig)
at OnnxStack.Core.Services.OnnxModelService.<>c__DisplayClass5_0.b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at OnnxStack.Core.Services.OnnxModelService.LoadModelAsync(IOnnxModelSetConfig model)
at OnnxStack.StableDiffusion.Services.StableDiffusionService.LoadModelAsync(IOnnxModelSetConfig model)
at OnnxStack.UI.UserControls.ModelPickerControl.LoadModel() in D:\Repositories\OnnxStack\OnnxStack.UI\UserControls\ModelPickerControl.xaml.cs:line 124
[1/5/2024 8:57:43 AM] [Information] [ModelPickerControl] [LoadModel] - 'dreamlike' Loaded., Elapsed: 3ms

I downloaded the huggingface repo in the readme and attempted to load, but get this in the logs.
I will note: this is looking for a file on the drive d, instead of a file in the download. I believe you may have fixed paths instead of relative paths in your repo.

Are you running this from OnnxStack.Console?

It sounds like you need to update the paths to your models in the appsettings.json file.

Can you share more information about:

  • What are you doing? Are you running the UI or the example console app?

I downloaded yesterday the 0.14.3 version, I have tested today with 0.15 just to make sure there wasnt an incidental fix.
I download the release for tensorrt and the mentioned onnx model dreamlike photoreal. I add it as a sd model.
I use the ui. I have not moved files since adding, so it shouldnt require manually updating paths in a settings file.
my comment about the d drive is because I did not have onnxstack or the onnx model on my d drive, but it is mentioned in the error message.

I checked the appsettings file just to be sure, and there is nothing there about the d drive.

Have you installed all the correct dependencies for the TensorRT version?

The error LoadLibrary failed with error 126 indicates that OnnxRuntime can't find one of the CUDA or TensorRT libraries.

The Cuda and TensorRT builds are experimental but do work, however you need to install a lot of Cuda dependencies

Name ONNX EP Device Requirements Status
OnnxStack_UI.zip DirectML CPU, AMD GPU, Nvidia GPU At least Windows10 Stable
OnnxStack_UI_Cuda.zip CUDA CPU, Nvidia GPU CUDA 11 and cuDNN toolkit Experimental
OnnxStack_UI_TensorRT.zip TensorRT CPU, Nvidia GPU CUDA 11 , cuDNN and TensorRT libraries Experimental

I would recommend the DirectML default build as its more compatible and it uses half the VRAM as the other builds

Links to the things that need to be installed for TensorRT if you would like.
CUDA 11 - https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html
CUDNN - https://developer.nvidia.com/cudnn
TensortRT https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html

You can ignore those file paths they seem to be coming from OnnxRuntime, so I assume their build server so not anything related to the error

cuda is installed. needed that for kobold
cudnn and tensorrt I downloaded, what do I actually run in these to get them installed? I thought they were external libraries that were to be included in a programs release since I use it with a1111 tensorrt extension fine.
also, where is this stated on the readme that these are required? the instructions are basically "download and run"

I attempted to run the base version and it loads, but crashes when I hit generate. cuda version had the same results as tensorrt.

There are no instructions for the UI because its just a simple example app

Unfortunately this library may not be compatible with your card, its still new and does not have many testers