SillyTavern / SillyTavern-Extras

Extensions API for SillyTavern.
GNU Affero General Public License v3.0
547 stars 123 forks source link

cannot import name 'PartialState' from 'accelerate' #12

Closed saklis closed 1 year ago

saklis commented 1 year ago

Following conda installation guide while executing python server.py --enable-modules=caption,summarize,classify I'm getting following error: cannot import name 'PartialState' from 'accelerate'.

I'm sure I'm doing something wrong, but I don't know enough about Python to figure it out :D

Trace:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\utils\import_utils.py", line 1153, in _get_module
    return importlib.import_module("." + module_name, self.__name__)
  File "C:\Users\user\.conda\envs\extras\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\pipelines\__init__.py", line 44, in <module>
    from .audio_classification import AudioClassificationPipeline
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\pipelines\audio_classification.py", line 21, in <module>
    from .base import PIPELINE_INIT_ARGS, Pipeline
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\pipelines\base.py", line 36, in <module>
    from ..modelcard import ModelCard
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\modelcard.py", line 48, in <module>
    from .training_args import ParallelMode
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\training_args.py", line 67, in <module>
    from accelerate import PartialState
ImportError: cannot import name 'PartialState' from 'accelerate' (C:\Users\user\AppData\Roaming\Python\Python310\site-packages\accelerate\__init__.py)

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

Traceback (most recent call last):
  File "E:\ai\TavernAI-extras\server.py", line 6, in <module>
    from transformers import AutoTokenizer, AutoProcessor, pipeline
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\utils\import_utils.py", line 1143, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\transformers\utils\import_utils.py", line 1155, in _get_module
    raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback):
cannot import name 'PartialState' from 'accelerate' (C:\Users\user\AppData\Roaming\Python\Python310\site-packages\accelerate\__init__.py)
Cohee1207 commented 1 year ago

It looks like a conflict in the Python modules installs. Could you try a miniconda environment? It would allow isolating your local modules from extras requirements.

saklis commented 1 year ago

I did. This is a result of installation using miniconda environment.

EDIT: I run everything again, using Anaconda Prompt. Full loggs attached. extras2.txt

Cohee1207 commented 1 year ago

I can confirm having the same error using the latest version of git transformers. I locked the version to be the last supported release version that doesn't depend on accelerate. Pushed to main, please git pull and try again https://github.com/Cohee1207/TavernAI-extras/commit/d3014d854504a29ff7aea1e42e54862dd3255c07

saklis commented 1 year ago

Works! Thank you for the help!