tin2tin / Pallaidium

PALLAIDIUM - a generative AI movie studio integrated in the Blender video editor.
GNU General Public License v3.0
975 stars 79 forks source link

NameError: name '_C' is not defined #85

Closed gerroon closed 10 months ago

gerroon commented 10 months ago

Blender 4.1, Windows, Pallaidium 1.7 (download from today, 11/18) I clicked on install dependencies, but it does not seem to need anything beside what is installed already and throws this error, also when using "Generate"

Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 808, in execute
    install_modules(self)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 589, in install_modules
    exec("import torch")
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\torch\__init__.py", line 457, in <module>
    for name in dir(_C):
NameError: name '_C' is not defined
Error: Python: Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 589, in install_modules
    exec("import torch")
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\torch\__init__.py", line 457, in <module>
    for name in dir(_C):
NameError: name '_C' is not defined
tin2tin commented 10 months ago

I notice you use 4.1, I don't know if there is some breaking change/bug, but first try to uninstall dependencies, close Blender, search the HDD for torch, delete if found, restart blender, install dependencies.

gerroon commented 10 months ago

It might be a 4.1 thing, so I went back to 4.0 but now I am getting invalid token :((

Error: Python: Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\Pallaidium\__init__.py", line 2930, in execute
    result = login(token=addon_prefs.hugginface_token)
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\huggingface_hub\_login.py", line 96, in login
    _login(token, add_to_git_credential=add_to_git_credential, write_permission=write_permission)
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\huggingface_hub\_login.py", line 275, in _login
    raise ValueError("Invalid token passed!")
ValueError: Invalid token passed!
gerroon commented 10 months ago

Lets not worry about the token, but uninstallinfg dependencies seems to be doing some weird stuff like installing numpy over and over again. Please see the log. Not sure if this is intentional

https://paste.debian.net/1298629/

gerroon commented 10 months ago

Also I uninstalled all the dependencies and reinstalled them using the addon pref, and I still have the same issue.Here is the new log during that

WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
Collecting transformers
  Using cached transformers-4.35.2-py3-none-any.whl.metadata (123 kB)
Requirement already satisfied: filelock in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (3.9.0)
Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (0.19.4)
Requirement already satisfied: numpy>=1.17 in C:\Blender\blender_alpha\4.1\python\lib\site-packages (from transformers) (1.26.2)
Requirement already satisfied: packaging>=20.0 in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (23.2)
Requirement already satisfied: pyyaml>=5.1 in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (6.0.1)
Collecting regex!=2019.12.17 (from transformers)
  Downloading regex-2023.10.3-cp310-cp310-win_amd64.whl.metadata (41 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.0/42.0 kB 511.8 kB/s eta 0:00:00
Requirement already satisfied: requests in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (2.28.1)
Collecting tokenizers<0.19,>=0.14 (from transformers)
  Using cached tokenizers-0.15.0-cp310-none-win_amd64.whl.metadata (6.8 kB)
Requirement already satisfied: safetensors>=0.3.1 in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (0.4.0)
Requirement already satisfied: tqdm>=4.27 in c:\users\USER\appdata\roaming\python\python310\site-packages (from transformers) (4.66.1)
Requirement already satisfied: fsspec>=2023.5.0 in c:\users\USER\appdata\roaming\python\python310\site-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (2023.9.1)
Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\users\USER\appdata\roaming\python\python310\site-packages (from huggingface-hub<1.0,>=0.16.4->transformers) (4.4.0)
Requirement already satisfied: colorama in c:\users\USER\appdata\roaming\python\python310\site-packages (from tqdm>=4.27->transformers) (0.4.6)
Requirement already satisfied: charset-normalizer<3,>=2 in C:\Blender\blender_alpha\4.1\python\lib\site-packages (from requests->transformers) (2.0.10)
Requirement already satisfied: idna<4,>=2.5 in C:\Blender\blender_alpha\4.1\python\lib\site-packages (from requests->transformers) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in C:\Blender\blender_alpha\4.1\python\lib\site-packages (from requests->transformers) (1.26.8)
Requirement already satisfied: certifi>=2017.4.17 in C:\Blender\blender_alpha\4.1\python\lib\site-packages (from requests->transformers) (2021.10.8)
Using cached transformers-4.35.2-py3-none-any.whl (7.9 MB)
Downloading regex-2023.10.3-cp310-cp310-win_amd64.whl (269 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 269.6/269.6 kB 3.3 MB/s eta 0:00:00
Using cached tokenizers-0.15.0-cp310-none-win_amd64.whl (2.2 MB)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
Installing collected packages: regex, tokenizers, transformers
  WARNING: The script transformers-cli.exe is installed in 'C:\Blender\blender_alpha\4.1\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.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
suno-bark 0.0.1a0 requires scipy, which is not installed.
Successfully installed regex-2023.10.3 tokenizers-0.15.0 transformers-4.35.2
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
WARNING: Ignoring invalid distribution -pencv-python (c:\users\USER\appdata\roaming\python\python310\site-packages)
Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 808, in execute
    install_modules(self)
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 642, in install_modules
    import_module(self, "bark", "git+https://github.com/suno-ai/bark.git")
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 535, in import_module
    exec("import " + module)
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\__init__.py", line 1, in <module>
    from .api import generate_audio, text_to_semantic, semantic_to_waveform, save_as_prompt
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\api.py", line 5, in <module>
    from .generation import codec_decode, generate_coarse, generate_fine, generate_text_semantic
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\generation.py", line 6, in <module>
    from encodec import EncodecModel
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\encodec\__init__.py", line 12, in <module>
    from .model import EncodecModel
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\encodec\model.py", line 14, in <module>
    import torch
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\torch\__init__.py", line 465, in <module>
    for name in dir(_C):
NameError: name '_C' is not defined
Info: Installing: torch module.
Info: Installing: accelerate module.
Error: Python: Traceback (most recent call last):
  File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\Pallaidium\__init__.py", line 535, in import_module
    exec("import " + module)
  File "<string>", line 1, in <module>
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\__init__.py", line 1, in <module>
    from .api import generate_audio, text_to_semantic, semantic_to_waveform, save_as_prompt
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\api.py", line 5, in <module>
    from .generation import codec_decode, generate_coarse, generate_fine, generate_text_semantic
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\bark\generation.py", line 6, in <module>
    from encodec import EncodecModel
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\encodec\__init__.py", line 12, in <module>
    from .model import EncodecModel
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\encodec\model.py", line 14, in <module>
    import torch
  File "C:\Users\USER\AppData\Roaming\Python\Python310\site-packages\torch\__init__.py", line 465, in <module>
    for name in dir(_C):
NameError: name '_C' is not defined
gerroon commented 10 months ago

This page says

Not sure precisely, but it seems that for me it was solved after installing Cython:
pip3 install Cython

https://github.com/pytorch/pytorch/issues/1633#issuecomment-418237093

tin2tin commented 10 months ago

Try this branch instead - I've tried to do some things about the installation process. Uninstall all dependencies first. Restart, then install this: https://github.com/tin2tin/Pallaidium/tree/Installation_fix

gerroon commented 10 months ago

Thanks I will give it a try. When I initially uninstalled dependencies and reinstalled them, it installed the non CUDA version of torch. I had to manually delete and reinstall it using pip install torch torchvision torchaudio –index-url https:download.pytorch.org/whl/cu118

tin2tin commented 10 months ago

Yeah, it is super frustrating. All of the python module installation is super hit&miss, most of the time it just does something unexpected, properly due pip is backing up old modules and also keep them as temp files, so it takes a lot of effort to get rid of a failing module.

tin2tin commented 10 months ago

I've updated the main code with the changes from the fork. Let me know if it solves your problems, so I can close this report if it does.

tin2tin commented 10 months ago

I installed https://pinokio.computer/ and that actually caused that error. So, now I uninstalled it, and try to remove all the stuff it installed on my machine, and then reinstall all Pallaidium dependencies. I hope this solves it.

My guess is that it is a bug in a specific version of Torch, so try to search all of your hard disk and delete all torch-related folders, and install dependencies.

gerroon commented 10 months ago

I had issues with cpu version of torch installed with other AI apps too. This pip install torch torchvision torchaudio –index-url https:download.pytorch.org/whl/cu118 generally fixes it once the old toch removed like you said.

tin2tin commented 10 months ago

This is basically pip hiding the module everywhere when you try to uninstall it: https://youtu.be/YtfQLyy43Xg?si=ImteCbsfLuYAOnim&t=788 which means you'll get into trouble when you try to change the version.

tin2tin commented 10 months ago

Thank you. Closing.