automatic icon indicating copy to clipboard operation
automatic copied to clipboard

[Issue]: Insightface module not installing

Open Machinekng opened this issue 2 years ago • 3 comments

Issue Description

When I attempt to use any of the Face script modules, SDNext tries to install the insightface module, but consistently fails without explanation.

For troubleshooting, I have tried different browsers (Firefox and Chrome), have reinstalled SDNext and also wiped venv to force all libraries to reinstall after the initial failed install.

Attached is the SDNext log, and the relevant console log for the session is also below.

24_2_14_insightface issue log.txt

Version Platform Description

app: SD.next updated: 2024-02-14 hash: a956be05 url: https://github.com/vladmandic/automatic/tree/dev

arch: AMD64 cpu: Intel64 Family 6 Model 151 Stepping 2, GenuineIntel system: Windows release: Windows-10-10.0.19045-SP0 python: 3.11.5

device: NVIDIA GeForce RTX 3080 (1) (sm_90) (8, 6) cuda: 12.1 cudnn: 8801 driver: 546.01

Relevant log output

Using VENV: C:\Users\machi\vlad-dev-refresh\venv
13:41:38-554579 INFO     Starting SD.Next
13:41:38-557569 INFO     Logger: file="C:\Users\machi\vlad-dev-refresh\sdnext.log" level=INFO size=742189 mode=append
13:41:38-559562 INFO     Python 3.11.5 on Windows
13:41:38-673182 INFO     Version: app=sd.next updated=2024-02-14 hash=a956be05
                         url=https://github.com/vladmandic/automatic/tree/dev
13:41:39-207328 INFO     Latest published version: 3c952675fefd2c94b817940ffbd4cd94fd5876c9 2024-02-10T10:42:56Z
13:41:39-222277 INFO     Platform: arch=AMD64 cpu=Intel64 Family 6 Model 151 Stepping 2, GenuineIntel system=Windows
                         release=Windows-10-10.0.19045-SP0 python=3.11.5
13:41:39-233240 INFO     nVidia CUDA toolkit detected: nvidia-smi present
13:41:39-340135 INFO     Extensions: disabled=[]
13:41:39-342128 INFO     Extensions: enabled=['Lora', 'sd-extension-chainner', 'sd-extension-system-info',
                         'sd-webui-agent-scheduler', 'sd-webui-controlnet', 'stable-diffusion-webui-images-browser',
                         'stable-diffusion-webui-rembg'] extensions-builtin
13:41:39-347111 INFO     Extensions: enabled=['adetailer'] extensions
13:41:39-350101 INFO     Startup: quick launch
13:41:39-351098 INFO     Verifying requirements
13:41:39-368041 INFO     Verifying packages
13:41:39-370035 INFO     Extensions: disabled=[]
13:41:39-373025 INFO     Extensions: enabled=['Lora', 'sd-extension-chainner', 'sd-extension-system-info',
                         'sd-webui-agent-scheduler', 'sd-webui-controlnet', 'stable-diffusion-webui-images-browser',
                         'stable-diffusion-webui-rembg'] extensions-builtin
13:41:39-378008 INFO     Extensions: enabled=['adetailer'] extensions
13:41:39-385981 INFO     Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}
13:41:39-388972 INFO     Command line args: []
13:41:45-417821 INFO     Load packages: {'torch': '2.2.0+cu121', 'diffusers': '0.26.3', 'gradio': '3.43.2'}
13:41:46-204872 INFO     Engine: backend=Backend.DIFFUSERS compute=cuda device=cuda attention="Scaled-Dot-Product"
                         mode=no_grad
13:41:46-261393 INFO     Device: device=NVIDIA GeForce RTX 3080 n=1 arch=sm_90 cap=(8, 6) cuda=12.1 cudnn=8801
                         driver=546.01
13:41:47-334950 INFO     Available VAEs: path="H:\SD-VAEs" items=8
13:41:47-338981 INFO     Disabled extensions: ['sd-webui-controlnet']
13:41:47-361904 INFO     Available models: path="H:\SD-Models" items=183 time=0.02
13:41:47-793120 INFO     Extension: script='extensions-builtin\Lora\scripts\lora_script.py'
                         13:41:47-790130 INFO     LoRA networks: available=574
                         folders=12
13:41:48-230045 INFO     Extension: script='extensions-builtin\sd-webui-agent-scheduler\scripts\task_scheduler.py'
                         Using sqlite file: extensions-builtin\sd-webui-agent-scheduler\task_scheduler.sqlite3
13:41:49-639695 INFO     Extension: script='extensions\adetailer\scripts\!adetailer.py' [-] ADetailer initialized.
                         version: 24.1.2, num models: 17
13:41:49-656410 INFO     Extensions init time: 2.07 img2imgalt.py=0.09 sd-webui-agent-scheduler=0.40
                         stable-diffusion-webui-images-browser=0.20 adetailer=1.21
13:41:49-709117 INFO     UI theme: name="black-teal" style=Auto base=sdnext.css
13:41:52-891569 INFO     Local URL: http://127.0.0.1:7860/
13:41:52-894523 INFO     Initializing middleware
13:41:53-030124 INFO     [AgentScheduler] Task queue is empty
13:41:53-033060 INFO     [AgentScheduler] Registering APIs
13:41:53-147748 INFO     Select: model="SDXL\juggernautXL_version6Rundiffusion [1fe6c7ec54]"
13:41:53-185943 INFO     Setting Torch parameters: device=cuda dtype=torch.float16 vae=torch.float16 unet=torch.float16
                         context=no_grad fp16=True bf16=None
13:41:53-191897 INFO     Loading VAE: model=H:\SD-VAEs\sdxl-vae-fp16-fix source=settings
13:41:53-586615 INFO     Autodetect: model="Stable Diffusion XL" class=StableDiffusionXLPipeline
                         file="H:\SD-Models\SDXL\juggernautXL_version6Rundiffusion.safetensors" size=6776MB
13:42:05-989287 INFO     Load embeddings: loaded=4 skipped=210 time=1.25
13:42:06-452737 INFO     Load model: time=12.84 load=12.84 native=512 {'ram': {'used': 1.35, 'total': 31.75}, 'gpu':
                         {'used': 8.15, 'total': 12.0}, 'retries': 0, 'oom': 0}
13:42:06-459713 INFO     Startup time: 27.06 torch=4.78 olive=0.06 gradio=1.18 libraries=1.87 extensions=2.07
                         face-restore=0.22 ui-en=0.84 ui-txt2img=0.06 ui-img2img=0.24 ui-control=0.08 ui-settings=0.15
                         ui-extensions=1.31 ui-defaults=0.28 launch=0.13 api=0.07 app-started=0.18 checkpoint=13.31
13:43:24-939157 INFO     MOTD: N/A
13:43:55-851065 INFO     Browser session: user=None client=127.0.0.1 agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64;
                         rv:122.0) Gecko/20100101 Firefox/122.0
13:45:26-751873 INFO     Select: model="Mixes - Photoreal\juggernaut_final [88967f03f2]"
13:45:29-269180 INFO     Setting Torch parameters: device=cuda dtype=torch.float16 vae=torch.float16 unet=torch.float16
                         context=no_grad fp16=True bf16=None
13:45:29-274163 INFO     Loading VAE: model=H:\SD-VAEs\vae-ft-mse-840000-ema-pruned.safetensors source=settings
13:45:29-275160 INFO     Autodetect: vae="Stable Diffusion" class=StableDiffusionPipeline file="H:\SD-Models\Mixes -
                         Photoreal\juggernaut_final.safetensors" size=2034MB
13:45:29-656599 INFO     Autodetect: model="Stable Diffusion" class=StableDiffusionPipeline file="H:\SD-Models\Mixes -
                         Photoreal\juggernaut_final.safetensors" size=2034MB
13:45:34-347057 INFO     Load embeddings: loaded=170 skipped=45 time=0.93
13:45:34-599215 INFO     Load model: time=5.09 load=5.09 native=512 {'ram': {'used': 1.56, 'total': 31.75}, 'gpu':
                         {'used': 3.31, 'total': 12.0}, 'retries': 0, 'oom': 0}
13:45:34-604198 INFO     Loading VAE: model=H:\SD-VAEs\vae-ft-mse-840000-ema-pruned.safetensors source=settings
13:45:34-608184 INFO     Autodetect: vae="Stable Diffusion" class=StableDiffusionPipeline file="H:\SD-Models\Mixes -
                         Photoreal\juggernaut_final.safetensors" size=2034MB
Progress  8.22it/s █████████████████████████████████ 100% 22/22 00:02 00:00 Base
13:45:45-828499 INFO     Saving: image="outputs\text\04061-juggernaut_final-photograph of a man.jpg" type=JPEG
                         resolution=512x512 size=0
13:45:45-834480 INFO     Processed: images=1 time=4.53 its=4.86 memory={'ram': {'used': 1.44, 'total': 31.75}, 'gpu':
                         {'used': 3.41, 'total': 12.0}, 'retries': 0, 'oom': 0}
13:46:02-259638 INFO     Installing package: insightface
13:46:06-308464 ERROR    Exception: No module named 'insightface'
13:46:06-309467 ERROR    Arguments: args=('task(25r17btlhsves88)', 'photograph of a man', '', [], 22, 10, 0, True,
                         False, False, 1, 1, 6, 6, 0.7, 0, 1, 1, -1.0, -1.0, 0, 0, 0, 512, 512, False, 0.5, 2, 'None',
                         False, 20, 0, 0, 5, 0.8, '', '', 0, 0, 0, 0, False, 4, 0.95, False, 0.6, 1, '#000000', 0, [],
                         8, 1, 'None', 'None', 'None', 'None', 0.5, 0.5, 0.5, 0.5, None, None, None, None, 0, 0, 0, 0,
                         1, 1, 1, 1, 'None', 16, 'None', 1, True, 'None', 2, True, 1, 0, True, 'none', 3, 4, 0.25,
                         0.25, False, False, {'ad_model': 'face_yolov8n.pt', 'ad_prompt': '', 'ad_negative_prompt': '',
                         'ad_confidence': 0.3, 'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1,
                         'ad_x_offset': 0, 'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None',
                         'ad_mask_blur': 4, 'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True,
                         'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False,
                         'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28,
                         'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint':
                         'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False,
                         'ad_sampler': 'Default', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1,
                         'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model':
                         'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1,
                         'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()},
                         {'ad_model': 'None', 'ad_prompt': '', 'ad_negative_prompt': '', 'ad_confidence': 0.3,
                         'ad_mask_k_largest': 0, 'ad_mask_min_ratio': 0, 'ad_mask_max_ratio': 1, 'ad_x_offset': 0,
                         'ad_y_offset': 0, 'ad_dilate_erode': 4, 'ad_mask_merge_invert': 'None', 'ad_mask_blur': 4,
                         'ad_denoising_strength': 0.4, 'ad_inpaint_only_masked': True,
                         'ad_inpaint_only_masked_padding': 32, 'ad_use_inpaint_width_height': False,
                         'ad_inpaint_width': 512, 'ad_inpaint_height': 512, 'ad_use_steps': False, 'ad_steps': 28,
                         'ad_use_cfg_scale': False, 'ad_cfg_scale': 7, 'ad_use_checkpoint': False, 'ad_checkpoint':
                         'Use same checkpoint', 'ad_use_vae': False, 'ad_vae': 'Use same VAE', 'ad_use_sampler': False,
                         'ad_sampler': 'Default', 'ad_use_noise_multiplier': False, 'ad_noise_multiplier': 1,
                         'ad_use_clip_skip': False, 'ad_clip_skip': 1, 'ad_restore_face': False, 'ad_controlnet_model':
                         'None', 'ad_controlnet_module': 'None', 'ad_controlnet_weight': 1,
                         'ad_controlnet_guidance_start': 0, 'ad_controlnet_guidance_end': 1, 'is_api': ()}, 3, 1, 1,
                         0.8, 8, 64, True, 1, 1, 0.5, 0.5, False, False, 'positive', 'comma', 0, False, False, '',
                         'None', '', 1, '', 'None', True, 0, 'None', 2, True, 1, 0, 0, '', [], 0, '', [], 0, '', [],
                         False, True, False, False, False, False, 0, 'FaceID', [{'name':
                         'C:\\Users\\machi\\AppData\\Local\\Temp\\gradio\\tmppv1g53ib.png', 'data':
                         'http://127.0.0.1:7860/file=C:\\Users\\machi\\AppData\\Local\\Temp\\gradio\\tmppv1g53ib.png',
                         'is_file': True}], 'FaceID Base', True, True, 1, 1, 1, 0.5, True, 'person', 1, 0.5, True)
                         kwargs={}
13:46:06-354278 ERROR    gradio call: ModuleNotFoundError
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\machi\vlad-dev-refresh\modules\call_queue.py:31 in f                                                       │
│                                                                                                                     │
│   30 │   │   │   try:                                                                                               │
│ > 31 │   │   │   │   res = func(*args, **kwargs)                                                                    │
│   32 │   │   │   │   progress.record_results(id_task, res)                                                          │
│                                                                                                                     │
│ C:\Users\machi\vlad-dev-refresh\modules\txt2img.py:86 in txt2img                                                    │
│                                                                                                                     │
│   85 │   p.script_args = args                                                                                       │
│ > 86 │   processed = scripts.scripts_txt2img.run(p, *args)                                                          │
│   87 │   if processed is None:                                                                                      │
│                                                                                                                     │
│ C:\Users\machi\vlad-dev-refresh\modules\scripts.py:480 in run                                                       │
│                                                                                                                     │
│   479 │   │   parsed = p.per_script_args.get(script.title(), args[script.args_from:script.args_to])                 │
│ > 480 │   │   processed = script.run(p, *parsed)                                                                    │
│   481 │   │   s.record(script.title())                                                                              │
│                                                                                                                     │
│ C:\Users\machi\vlad-dev-refresh\modules\face\__init__.py:114 in run                                                 │
│                                                                                                                     │
│   113 │   │   │   from modules.face.insightface import get_app                                                      │
│ > 114 │   │   │   app = get_app('buffalo_l')                                                                        │
│   115 │   │   │   from modules.face.faceid import face_id                                                           │
│                                                                                                                     │
│ C:\Users\machi\vlad-dev-refresh\modules\face\insightface.py:21 in get_app                                           │
│                                                                                                                     │
│   20 │   if insightface_app is None or mp_name != instightface_mp:                                                  │
│ > 21 │   │   from insightface.app import FaceAnalysis                                                               │
│   22 │   │   import huggingface_hub as hf                                                                           │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
ModuleNotFoundError: No module named 'insightface'

Backend

Diffusers

Branch

Dev

Model

SD 1.5

Acknowledgements

  • [X] I have read the above and searched for existing issues
  • [X] I confirm that this is classified correctly and its not an extension issue

Machinekng avatar Feb 14 '24 19:02 Machinekng

you can see it tried to install insightface on first use as it should:

13:46:02-259638 INFO Installing package: insightface

but if failed - i don't know why. i've updated dev branch to capture info on failure, not just make it silent.

vladmandic avatar Feb 15 '24 14:02 vladmandic

Alright. It looks like a permission error.

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\machi\\vlad-dev-refresh\\venv\\Lib\\site-packages\\cv2\\cv2.pyd'

I couldn't figure out the permission issue, so I just ran pip install --upgrade insightface from the admin command prompt, and that seemed to work fine.

Now that insightface was installed, I tried to run faceID, and got the ONNX & CUDA/cudnn compatibility error.

2024-02-15 08:45:09,457 | sd | ERROR | call_queue | Exception: 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.

So, this looks like the ONNX cuda version fallback issue that I think was noted in a couple places, so this issue maybe redundant. To see if I could get the onnxruntime-gpu to work, I installed CUDA 12.2 and cudnn 8.9.26 per the version recommendation and made a new git clone for SDNext dev. I also reinstalled onnxruntime-gpu per the instructions for using 1.17 on CUDA 12.2. I don't think SDNext was recognizing the fresh CUDA/cudnn, but using the manual reinstall for the specific onnxruntime-gpu build did allow faceID to run.

Machinekng avatar Feb 15 '24 15:02 Machinekng

I couldn't figure out the permission issue,

permission issue is weird.

so I just ran pip install --upgrade insightface from the admin command prompt, and that seemed to work fine.

unless you activated venv, that installed insightface into python's current user context, not in venv.
nothing wrong with that, just so you know.

I also reinstalled onnxruntime-gpu

good job tracking down onnxruntime-gpu for cuda 12.2. but even without it, it should work using cpu and error above should trigger a fallback, not an abort.

anyhow, seems like issue is resolved.

vladmandic avatar Feb 15 '24 15:02 vladmandic