carson-katri / dream-textures

Stable Diffusion built-in to Blender
GNU General Public License v3.0
7.81k stars 426 forks source link

ModuleNotFoundErrors: No modules named 'diffusers' nor 'huggingface_hub' #430

Closed fyyv closed 1 year ago

fyyv commented 1 year ago

Description

Using Linux (CUDA), I was successfully able to download developer dependencies, but when downloading a model, I received the following error:

Exception: Traceback (most recent call last):
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 271, in _receive
    response = getattr(self, message.method_name)(*message.args, **message.kwargs)
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actions/huggingface_hub.py", line 62, in hf_list_installed_models
    from diffusers.utils import DIFFUSERS_CACHE
ModuleNotFoundError: No module named 'diffusers'

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

Traceback (most recent call last):
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 111, in run_callbacks
    done_callback(self)
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/preferences.py", line 145, in on_done
    set_model_list('installed_models', Generator.shared().hf_list_installed_models().result())
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 64, in result
    raise self._exception
ModuleNotFoundError: No module named 'diffusers'

Further, when attempting to use the Find Models feature to search Hugging Face Hub for a model, I received this error:

Exception: Traceback (most recent call last):
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 271, in _receive
    response = getattr(self, message.method_name)(*message.args, **message.kwargs)
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actions/huggingface_hub.py", line 45, in hf_list_models
    from huggingface_hub import HfApi, ModelFilter
ModuleNotFoundError: No module named 'huggingface_hub'

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

Traceback (most recent call last):
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 111, in run_callbacks
    done_callback(self)
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/preferences.py", line 155, in on_done
    set_model_list('model_results', future.result())
  File "/home/username/.config/blender/3.3/scripts/addons/dream-textures/generator_process/actor.py", line 58, in result
    raise self._exception
ModuleNotFoundError: No module named 'huggingface_hub'

I can verify that folders named diffusers and huggingface_hub exist in /home/username/.config/blender/3.3/scripts/addons/dream-textures/.python_dependencies and not anywhere else.

I have manually downloaded the models I'd like to use but the Import Checkpoint file creates the same diffusers error as above.

It may be possible that a SD-related cache elsewhere on my machine is conflicting. I used other SD tools when 1.4 came out.

It is also possible that the bug is related to Blender version 3.3. That's currently the latest version supporting Octane, otherwise I'd use the latest builds.

Thanks for building a great tool. I'm looking forward to trying it out!

Steps to Reproduce

  1. Install the addon on Linux (CUDA) in Blender 3.3.
  2. Install developer dependencies.
  3. Attempt to download or search for a model.

Expected Behavior

Successfully complete a search for a model, or successfully download a model.

Addon Version

Other (Built from source)

GPU

NVIDIA

carson-katri commented 1 year ago

Looks like the dependencies were not downloaded successfully. In the dream_textures addon folder, is the .python_dependencies folder empty? There should be a folder diffusers and huggingface_hub in there (among others)

fyyv commented 1 year ago

I can verify that folders named diffusers and huggingface_hub exist in /home/username/.config/blender/3.3/scripts/addons/dream-textures/.python_dependencies and not anywhere else. There are 137 items in .python_dependencies.

Out of curiosity I reinstalled the addon and got the dependencies again. After collecting packages, it successfully builds the wheel for diffusers, successfully builds diffusers, and claims it has successfully installed all collected packages.

One thing I saw in an error tooltip which I didn't see in the console was when I tried to import a checkpoint file, No module named 'torch'. All other errors are still happening, unfortunately, and the dependency torch exists in .python_dependencies as well.

Any ideas?

NullSenseStudio commented 1 year ago

Have you tried restarting Blender after installing dependencies? Could be an issue with the backend already being started and not being able to load the new modules while its running.

fyyv commented 1 year ago

Yes, I have restarted both Blender and my computer at all different stages of installation. I verified I have full write access to all directories used by Blender, and a firewall isn't preventing connections. In case 3.3 had been the problem, I also tried 3.4 and 3.5. Logs indicate nothing goes wrong when installing dependencies. The files exist, they are just not being used.

No success so far with this or any previous version of the addon on Linux. In any case, I appreciate the help so far.

TutajITeraz commented 1 year ago

I have exactly the same problem. .python_dependencies are installed correctly, but

ModuleNotFoundError: No module named 'diffusers'

shows up when I try to import checkpoint. Other Stable Diffusion front ends are working correctly.

NullSenseStudio commented 1 year ago

I've found that this can be caused by the default context that multiprocessing has for unix based systems being different from windows and macOS. https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

nantille commented 1 year ago

Much appreciated @NullSenseStudio I was just trying the add-on on Linux and had the same issue. Your fix works and allows me to download SD 2.1.