글 작성자: 만렙개발자

diffusers를 업데이트하고 아래와 같은 에러가 발생했다.

 

File "/root/projects/dreambooth_qm_test/examples/dreambooth/train_dreambooth.py", line 49, in <module>
    from diffusers.training_utils import enable_full_determinism
ImportError: cannot import name 'enable_full_determinism' from 'diffusers.training_utils' (/root/anaconda3/envs/py31/lib/python3.10/site-packages/diffusers/training_utils.py)

 

검색해도 별로 답은 나오지 않았다. (그래서 블로그를 쓴다.)

운이 좋게도 내 train code에서는 이미 enable_full_determinism 함수가 주석처리 되어있었다.

import하는 데에서 주석처리하면 끝나는 문제였다. (사실 새로운 에러를 만났다.)

 

하지만, 이왕 이렇게 알게된 것, enable_full_determinism에 대해서 알아보자.

 

enable_full_determinism 함수는 분산 학습 중에 "재현 가능한 동작"을 위한 helper 함수입니다. seed와 관련해서, 분산 학습시 실행시마다 다른 결과를 얻지 않을 수 있도록 완전히(full) 결정적인(deterministic) 결과를 내도록 도와주는 함수이다.

Helper function for reproducible behavior during distributed training. 

 

관련문서:
https://pytorch.org/docs/stable/notes/randomness.html for pytorch
https://www.tensorflow.org/api_docs/python/tf/config/experimental/enable_op_determinism for tensorflow

 

과거에는 diffusers/training_utils에 enable_full_determinism 함수가 있었나보다.

현재는 transformers.enable_full_determinism 를 사용하는 것 같다. (전후관계는 귀찮아서 찾지 않았다.)