Gourieff / sd-webui-reactor

Fast and Simple Face Swap Extension for StableDiffusion WebUI (A1111 SD WebUI, SD WebUI Forge, SD.Next, Cagliostro)
GNU Affero General Public License v3.0
2.48k stars 264 forks source link

Error onnxruntime with Face Model Build #354

Closed Valirius closed 7 months ago

Valirius commented 7 months ago

First, confirm

What happened?

When I try to build the model I get the error "onnxruntime". I tried to install it, but it looks like it is installed in the WinOS itself instead of the portable version. if you run the command just from the folder

python.exe G:\Webui-Forge\system\python\Scripts\pip.exe install onnxruntime-gpu

If you run from the folder where the Python file is -

G:\Webui-Forge\system\python>python.exe G:\Webui-Forge\system\python\Scripts\pip.exe install onnxruntime-gpu 

I get the answer that everything is already installed

Requirement already satisfied: onnxruntime-gpu in g:\webui-forge\system\python\lib\site-packages (1.17.0) Requirement already satisfied: coloredlogs in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (15.0.1) Requirement already satisfied: flatbuffers in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (23.5.26) Requirement already satisfied: numpy>=1.21.6 in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (1.26.2) Requirement already satisfied: packaging in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (23.2) Requirement already satisfied: protobuf in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (3.20.3) Requirement already satisfied: sympy in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (1.12) Requirement already satisfied: humanfriendly>=9.1 in g:\webui-forge\system\python\lib\site-packages (from coloredlogs->onnxruntime-gpu) (10.0) Requirement already satisfied: mpmath>=0.19 in g:\webui-forge\system\python\lib\site-packages (from sympy->onnxruntime-gpu) (1.3.0) Requirement already satisfied: pyreadline3 in g:\webui-forge\system\python\lib\site-packages (from humanfriendly>=9.1->coloredlogs->onnxruntime-gpu) (3.4.1)

After uninstalling (from instruction) and installing I get this log

WARNING: Ignoring invalid distribution -nnxruntime (g:\webui-forge\system\python\lib\site-packages) Collecting onnxruntime-gpu Using cached onnxruntime_gpu-1.17.0-cp310-cp310-win_amd64.whl.metadata (4.3 kB) Requirement already satisfied: coloredlogs in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (15.0.1) Requirement already satisfied: flatbuffers in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (23.5.26) Requirement already satisfied: numpy>=1.21.6 in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (1.26.2) Requirement already satisfied: packaging in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (23.2) Requirement already satisfied: protobuf in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (3.20.3) Requirement already satisfied: sympy in g:\webui-forge\system\python\lib\site-packages (from onnxruntime-gpu) (1.12) Requirement already satisfied: humanfriendly>=9.1 in g:\webui-forge\system\python\lib\site-packages (from coloredlogs->onnxruntime-gpu) (10.0) Requirement already satisfied: mpmath>=0.19 in g:\webui-forge\system\python\lib\site-packages (from sympy->onnxruntime-gpu) (1.3.0) Requirement already satisfied: pyreadline3 in g:\webui-forge\system\python\lib\site-packages (from humanfriendly>=9.1->coloredlogs->onnxruntime-gpu) (3.4.1) Using cached onnxruntime_gpu-1.17.0-cp310-cp310-win_amd64.whl (148.6 MB)
WARNING: Ignoring invalid distribution -nnxruntime (g:\webui-forge\system\python\lib\site-packages) Installing collected packages: onnxruntime-gpu
WARNING: The script onnxruntime_test.exe is installed in 'G:\Webui-Forge\system\python\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed onnxruntime-gpu-1.17.0

but when I try to generate a face model, I get the same error

Steps to reproduce the problem

Try to build face model

Sysinfo

SD Forge

Relevant console log

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "G:\Webui-Forge\system\python\lib\site-packages\gradio\routes.py", line 488, in run_predict
    output = await app.get_blocks().process_api(
  File "G:\Webui-Forge\system\python\lib\site-packages\gradio\blocks.py", line 1431, in process_api
    result = await self.call_function(
  File "G:\Webui-Forge\system\python\lib\site-packages\gradio\blocks.py", line 1103, in call_function
    prediction = await anyio.to_thread.run_sync(
  File "G:\Webui-Forge\system\python\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "G:\Webui-Forge\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
    return await future
  File "G:\Webui-Forge\system\python\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
    result = context.run(func, *args)
  File "G:\Webui-Forge\system\python\lib\site-packages\gradio\utils.py", line 707, in wrapper
    response = f(*args, **kwargs)
  File "G:\Webui-Forge\webui\extensions\sd-webui-reactor\scripts\reactor_swapper.py", line 614, in build_face_model
    face_model = analyze_faces(image)
  File "G:\Webui-Forge\webui\extensions\sd-webui-reactor\scripts\reactor_swapper.py", line 275, in analyze_faces
    face_analyser = copy.deepcopy(getAnalysisModel())
  File "G:\Webui-Forge\webui\extensions\sd-webui-reactor\scripts\reactor_swapper.py", line 119, in getAnalysisModel
    ANALYSIS_MODEL = insightface.app.FaceAnalysis(
  File "G:\Webui-Forge\webui\extensions\sd-webui-reactor\scripts\console_log_patch.py", line 48, in patched_faceanalysis_init
    model = model_zoo.get_model(onnx_file, **kwargs)
  File "G:\Webui-Forge\system\python\lib\site-packages\insightface\model_zoo\model_zoo.py", line 96, in get_model
    model = router.get_model(providers=providers, provider_options=provider_options)
  File "G:\Webui-Forge\webui\extensions\sd-webui-reactor\scripts\console_log_patch.py", line 21, in patched_get_model
    session = PickableInferenceSession(self.onnx_file, **kwargs)
  File "G:\Webui-Forge\system\python\lib\site-packages\insightface\model_zoo\model_zoo.py", line 25, in __init__
    super().__init__(model_path, **kwargs)
  File "G:\Webui-Forge\system\python\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 432, in __init__
    raise fallback_error from e
  File "G:\Webui-Forge\system\python\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 427, in __init__
    self._create_inference_session(self._fallback_providers, None)
  File "G:\Webui-Forge\system\python\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 483, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
RuntimeError: D:\a\_work\1\s\onnxruntime\python\onnxruntime_pybind_state.cc:857 onnxruntime::python::CreateExecutionProviderInstance CUDA_PATH is set but CUDA wasnt able to be loaded. Please install the correct version of CUDA andcuDNN as mentioned in the GPU requirements page  (https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements),  make sure they're in the PATH, and that your GPU is supported.

Additional information

No response

Valirius commented 7 months ago

I'll try to install the latest version of "cuda 12.3.2", maybe it will eat))

Valirius commented 7 months ago

It seems to work after installing a newer version of "Cuda 12.3.2" on Windows