[GH-ISSUE #12] cannot import name 'PartialState' from 'accelerate' #7

Closed
opened 2026-10-15 18:03:20 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @saklis on GitHub (Apr 19, 2023).
Original GitHub issue: https://github.com/SillyTavern/SillyTavern-Extras/issues/12

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)
Originally created by @saklis on GitHub (Apr 19, 2023). Original GitHub issue: https://github.com/SillyTavern/SillyTavern-Extras/issues/12 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) ```
Author
Owner

@Cohee1207 commented on GitHub (Apr 19, 2023):

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.

<!-- gh-comment-id:1515133436 --> @Cohee1207 commented on GitHub (Apr 19, 2023): 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.
Author
Owner

@saklis commented on GitHub (Apr 19, 2023):

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

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

<!-- gh-comment-id:1515187463 --> @saklis commented on GitHub (Apr 19, 2023): I did. This is a result of installation using miniconda environment. EDIT: I run everything again, using Anaconda Prompt. Full loggs attached. [extras2.txt](https://github.com/Cohee1207/TavernAI-extras/files/11276573/extras2.txt)
Author
Owner

@Cohee1207 commented on GitHub (Apr 19, 2023):

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
github.com/Cohee1207/TavernAI-extras@d3014d8545

<!-- gh-comment-id:1515215803 --> @Cohee1207 commented on GitHub (Apr 19, 2023): 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
Author
Owner

@saklis commented on GitHub (Apr 19, 2023):

Works! Thank you for the help!

<!-- gh-comment-id:1515234363 --> @saklis commented on GitHub (Apr 19, 2023): Works! Thank you for the help!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SillyTavern/SillyTavern-Extras#7
No description provided.