Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Launching web-gui with CUDA #5863

Closed
1 task done
SANCHEI opened this issue Mar 4, 2024 · 15 comments
Closed
1 task done

[bug]: Launching web-gui with CUDA #5863

SANCHEI opened this issue Mar 4, 2024 · 15 comments
Labels
bug Something isn't working

Comments

@SANCHEI
Copy link

SANCHEI commented Mar 4, 2024

Is there an existing issue for this problem?

  • I have searched the existing issues

Operating system

Windows

GPU vendor

Nvidia (CUDA)

GPU model

2060

GPU VRAM

8Gb

Version number

3.7.0

Browser

Opera: 107.0.5045.37

Python dependencies

No response

What happened

After completing the installation, I proceeded to execute invoke.bat, selected option 1, confirmed it, and encountered an error.
I attempted reinstall through the invoke.bat, then retried launching the GUI and encountered the same errors.

Starting the InvokeAI browser-based UI..
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\ai_programs\invoke\.venv\Scripts\invokeai-web.exe\__main__.py", line 4, in <module>
    from invokeai.app.api_app import invoke_api
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\api_app.py", line 43, in <module>
    from .api.dependencies import ApiDependencies
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\api\dependencies.py", line 12, in <module>
    from ..services.board_images.board_images_default import BoardImagesService
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\board_images\board_images_default.py", line 3, in <module>
    from invokeai.app.services.invoker import Invoker
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\invoker.py", line 9, in <module>
    from .shared.graph import Graph, GraphExecutionState
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\shared\graph.py", line 12, in <module>
    from invokeai.app.invocations import *  # noqa: F401 F403
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\invocations\controlnet_image_processors.py", line 9, in <module>
    from controlnet_aux import (
ModuleNotFoundError: No module named 'controlnet_aux'

What you expected to happen

I expected to launch web GUI

How to reproduce the problem

No response

Additional context

No response

Discord username

No response

@SANCHEI SANCHEI added the bug Something isn't working label Mar 4, 2024
@the-space-fish
Copy link

I had the same issue last week upon updating to 3.7 from 3.4 with the latest install.bat (I'd put off updating for a while for fear of just such a thing happening after I ran into some of the now-known issues when updating to 3.4!), and saw some older issues posted for it as well (such as #5734 , which was closed with a suggested fix, but no confirmation).

I tried doing an update to force dependency reinstallation, tried running the repair installation option, tried reinstalling again from the 3.7 install script, but didn't have any luck. I tried manually uninstalling and re-installing the controlnet_aux module, and still got that error. The module showed up in a "pip list" in the VENV, so I was about ready to pull my hair out in flabbergastery.

Finally, I noticed that in the relevant site-packages directory, that regardless of whether I installed it individually or by the script, controlnet_aux was only ever creating the dist-info folder, and not the actual module contents (which explains why it could show up as installed without actually being there). So at that point I just manually downloaded the package (you can grab the current version here: https://pypi.org/project/controlnet-aux/0.0.7/ ) and extracted the module contents folder straight over into the site-packages directory, and that took care of the problem.

I'm not versed enough in Python to figure out exactly what was going on here, but it seems like there's some flakiness to this package that might warrant a little extra guarding against.

@adriantiron
Copy link

@the-space-fish Thanks a bunch for the fix, that's exactly what the problem was! I just wanted to add a few details, as some might still struggle with this information. What I did was download the controlnet_aux-0.0.7.tar.gz file from the pypi page and extract ONLY the controlnet_aux folder from the src folder and place it in ...\InvokeAI\.venv\Lib\site-packages. The name of the folder is important, it has to be controlnet_aux, otherwise python doesn't know where to import from.

Sorry if this is simple stuff, I thought it might still be helpful.

@the-space-fish
Copy link

@adriantiron - yes, thanks for adding in the details! I'd have been more explicit, but was writing from memory on a different computer without the installation handy.

@SANCHEI
Copy link
Author

SANCHEI commented Mar 7, 2024

Downloaded and put the controlnet_aux folder from src now the error is a little different.

Desired action:
1. Generate images with the browser-based interface
2. Run textual inversion training
3. Merge models (diffusers type only)
4. Download and install models
5. Change InvokeAI startup options
6. Re-run the configure script to fix a broken install or to complete a major upgrade
7. Open the developer console
8. Update InvokeAI (DEPRECATED - please use the installer)
9. Run the InvokeAI image database maintenance script
10. Command-line help
Q - Quit
Please enter 1-10, Q: [1] 1
Starting the InvokeAI browser-based UI..
>> patchmatch.patch_match: INFO - Downloading patchmatch libraries from github release https://github.com/invoke-ai/PyPatchMatch/releases/download/0.1.1/libpatchmatch_windows_amd64.dll
100%|█████████████████████████████████████████████████████████████████████████████| 47.0k/47.0k [00:00<00:00, 1.27MB/s]
>> patchmatch.patch_match: INFO - Downloading patchmatch libraries from github release https://github.com/invoke-ai/PyPatchMatch/releases/download/0.1.1/opencv_world460.dll
100%|█████████████████████████████████████████████████████████████████████████████| 61.4M/61.4M [00:10<00:00, 5.94MB/s]
[2024-03-08 01:29:02,534]::[InvokeAI]::INFO --> Patchmatch initialized
Traceback (most recent call last):
  File "C:\Users\SANCHEI\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\SANCHEI\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\ai_programs\invoke\.venv\Scripts\invokeai-web.exe\__main__.py", line 4, in <module>
    from invokeai.app.api_app import invoke_api
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\api_app.py", line 43, in <module>
    from .api.dependencies import ApiDependencies
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\api\dependencies.py", line 12, in <module>
    from ..services.board_images.board_images_default import BoardImagesService
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\board_images\board_images_default.py", line 3, in <module>
    from invokeai.app.services.invoker import Invoker
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\invoker.py", line 9, in <module>
    from .shared.graph import Graph, GraphExecutionState
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\services\shared\graph.py", line 12, in <module>
    from invokeai.app.invocations import *  # noqa: F401 F403
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\app\invocations\latent.py", line 78, in <module>
    DEFAULT_PRECISION = choose_precision(choose_torch_device())
  File "D:\ai_programs\invoke\.venv\lib\site-packages\invokeai\backend\util\devices.py", line 35, in choose_precision
    device_name = torch.cuda.get_device_name(device)
  File "D:\ai_programs\invoke\.venv\lib\site-packages\torch\cuda\__init__.py", line 419, in get_device_name
    return get_device_properties(device).name
  File "D:\ai_programs\invoke\.venv\lib\site-packages\torch\cuda\__init__.py", line 452, in get_device_properties
    raise AssertionError("Invalid device id")
AssertionError: Invalid device id

image

@the-space-fish
Copy link

the-space-fish commented Mar 8, 2024

That error seems to be implying it can't access your CUDA device (GPU), so I wonder if this section from the release notes would help you out?

Invoke might revert to CPU (NVIDIA GPU only)
Some users have experienced torch reverting to the CPU rather than their GPU. To fix this follow these steps:
Launch your invoke.bat / invoke.sh and select the option to open the developer console
Run: pip install --force-reinstall torch==2.1.2 --index-url https://download.pytorch.org/whl/cu121
If you run into an error with typing_extensions, run: pip install -U typing-extensions
If there is an error with fsspec, run pip install -U fsspec==2023.5.0

@adriantiron
Copy link

You can also try something to see how many CUDA capable devices are seen:

  1. Open invoke.bat and input 7 for the desired action.
  2. Type python. Cmd line should change to >>>.
  3. Type import torch.
  4. Type torch.cuda.device_count().

Please post a screenshot here.

@SANCHEI
Copy link
Author

SANCHEI commented Mar 8, 2024

4. torch.cuda.device_count()
image

(.venv) D:\ai_programs\invoke>python
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.device_count()
1

@SANCHEI
Copy link
Author

SANCHEI commented Mar 8, 2024

That error seems to be implying it can't access your CUDA device (GPU), so I wonder if this section from the release notes would help you out?

Invoke might revert to CPU (NVIDIA GPU only)
Some users have experienced torch reverting to the CPU rather than their GPU. To fix this follow these steps:
Launch your invoke.bat / invoke.sh and select the option to open the developer console
Run: pip install --force-reinstall torch==2.1.2 --index-url https://download.pytorch.org/whl/cu121
If you run into an error with typing_extensions, run: pip install -U typing-extensions
If there is an error with fsspec, run pip install -U fsspec==2023.5.0

About that. I tried reinstalling torch and got an error. Then I installed fsspec and started the torch installation again - I got the same errors.
WindowsTerminal_2OmEyc82ZF

@adriantiron
Copy link

adriantiron commented Mar 8, 2024

Try installing controlnet-aux, I'm guessing it doesn't find the dist-info: pip install -U controlnet-aux==0.0.7. You can check the site-packages folder from venv again after, if you don't have the full pair of <package> and <package>.dist-info apply the fix above.

P.S.: Don't start the torch installation again after dealing with the dependencies. That error does not invalidate the torch installation.

@SANCHEI
Copy link
Author

SANCHEI commented Mar 8, 2024

Well, at least we know the GPU is detected... In this case, did you try the latest suggestion from @the-space-fish ?

I'm not sure if it can see the video card. During installation it suggested Cuda, and at the time of reinstallation via invoke.bat it couldn't detect the video card.
WindowsTerminal_rtdFQkWcIJ
WindowsTerminal_Xv3w2xtRBI

@adriantiron
Copy link

adriantiron commented Mar 8, 2024

If I may, if you don't have a strong reason for choosing InvokeAI, can I suggest Automatic1111? I switched to that and had 0 problems installing and using it.

@SANCHEI
Copy link
Author

SANCHEI commented Mar 8, 2024

Try installing controlnet-aux, I'm guessing it doesn't find the dist-info: pip install -U controlnet-aux==0.0.7. You can check the site-packages folder from venv again after, if you don't have the full pair of <package> and <package>.dist-info apply the fix above.

P.S.: Don't start the torch installation again after dealing with the dependencies. That error does not invalidate the torch installation.

A new folder appeared, but it didn't help the case.
About AUTOMATIC1111 it is handy but it takes a long time to generate images compared to Voltraml, Vladmandic, EasyDiffusion.
image

@adriantiron
Copy link

You can also try something to see how many CUDA capable devices are seen:

1. Open invoke.bat and input `7` for the desired action.

2. Type `python`. Cmd line should change to `>>>`.

3. Type `import torch`.

4. Type `torch.cuda.device_count()`.

Please post a screenshot here.

Just like in this reply, do the same but for 2 more lines:

  • torch.cuda.current_device()
  • torch.cuda.get_device_name()

@SANCHEI
Copy link
Author

SANCHEI commented Mar 8, 2024

You can also try something to see how many CUDA capable devices are seen:

1. Open invoke.bat and input `7` for the desired action.

2. Type `python`. Cmd line should change to `>>>`.

3. Type `import torch`.

4. Type `torch.cuda.device_count()`.

Please post a screenshot here.

Just like in this reply, do the same but for 2 more lines:

  • torch.cuda.current_device()
  • torch.cuda.get_device_name()
(.venv) D:\ai_programs\invoke>python
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.device_count()
1
>>> torch.cuda.current_device()
0
>>> torch.cuda.get_device_name()
'NVIDIA GeForce RTX 2060 SUPER'
>>>

image

@adriantiron
Copy link

Everything seems to be fine here. I'm stumped, the only other thing I would try doing is start from scratch... Sorry, maybe someone else has better ideas.

@SANCHEI SANCHEI closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants