본문 바로가기

Error and Solve

[에러 해결] Cannot import name 'PartialState' from 'accelerate / pip install accelerate==0.33.0 transformers==4.43.3

반응형

 

 

 

 

Cannot import name 'PartialState' from 'accelerate

 

 

1. cannot import name 'PartialState' from 'accelerate 

 

Accelerate 을 쓸 때 initialize 초기화를 위해서 PartialState()를 써야 했다. 

하지만 위와 같이 PartialState를 인식 못하는 에러가 발생했다. 

 

 

실행했던 코드는 

from accelerate import PartialState
state = PartialState()

 

위와 같다

 

 

 

 

해결 : accelerate과 transformers 재설치

 

이를 해결하기 위해 accelerate와 transformers 패키지를 여러 버전으로 재설치를 진행해보았고 

돌아가는 버전을 발견했다. 

 

accelerate             0.33.0
transformers           4.43.3

 

accelerate             0.33.0
transformers           4.43.3

 

pip list | grep accelerate 

pip list | grep transformers 를 했을 때 나오는 패키지 버전 

 

 

 

위와 같은 패키지를 설치하면 내 경우에서는 돌아갔다. 

pip install accelerate==0.33.0 transformers==4.43.3

pip install accelerate==0.33.0 transformers==4.43.3

 

 

 

 

 

 

 


 

Reference

 

https://stackoverflow.com/questions/76363436/cannot-import-name-partialstate-from-accelerate-when-using-huggingface-pipel

 

cannot import name 'PartialState' from 'accelerate' when using Huggingface pipeline on Kaggle notebook?

When import pipeline from Huggingface on Kaggle notebook, from transformers import pipeline it throws this error: /opt/conda/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:98:

stackoverflow.com

 

 

 

 

 

반응형