KLUE-benchmark / KLUE

📖 Korean NLU Benchmark

Home Page:https://klue-benchmark.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[KLUE-RE] huggingface klue/roberta-base 오류 문의

LeejwUniverse opened this issue · comments

Description

안녕하세요. Klue/roberta-base 모델을
MODEL_NAME = "klue/roberta-base"
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model_config = AutoConfig.from_pretrained(MODEL_NAME)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, config=model_config)
위와 같이 auto로 불러온 후 sentence classification task를 학습 시키려 하는데, 아래와 같은 오류가 발생했습니다.

RuntimeError: CUDA error: CUBLAS_STATUS_NOT_INITIALIZED when calling cublasCreate(handle)

klue/bert-base는 학습이 되어, 모델 자체나 huggingface의 포팅에 문제점이 있는 것 같아 문의 드립니다.
klue/roberta 계열 baseline 모델을 사용하기 위해 따로 지켜야 할 부분들이 있을까요?

감사합니다.

(Optional) Suggestion

안녕하세요 @LeejwUniverse 님!
제가 간단히 klue/roberta-base에 대해서 tokenizer, config, model 로드하고 forward 했을 때는 문제가 없는 것 같습니다.
혹시 학습시키실 때 환경이나 에러에 대한 구체적인 내용을 좀 더 알려주실 수 있으실까요? 완벽히 동일한 환경에서 klue/bert-base은 문제가 없나요?

image
로드 자체는 되는 것 같은데, trainer를 통해서 forward하면서 위와 같은 cuda에러가 발생 했습니다.

완벽히 동일한 환경에서 AutoForSentenceClassification 으로 불러왔을때, klue/bert-base는 이상없이 trainer 사용해서 학습이 되었습니다. 다른 공개된 model들 roberta, bert를 테스트 했을때도 학습이 되었고, klue/roberta 계열만 전부 동일한 에러가 발생해 따로 설정 해줘야 하는 부분이 있는 지 궁금했습니다.
다른 서버로 확인해봤을때도, klue/roberta만 동일한 에러가 발생했습니다.

안녕하세요 @LeejwUniverse 님 혹시 저도 같은 오류가 발생합니다 skt/kobert-base-v1 에서는 동일한 오류가 나지 않을까하고 질문드립니다.

tokenizer에 return_token_type_ids=False 를 넣음으로써 저는 해결하였습니다.

저도 같은 문제로 고통받고 있습니다....

tokenizer에 return_token_type_ids = False argument를 넣어주지 않는다면,
trainer에서 돌렸을 때 다음 134번 줄과 같이 token_type_ids embedding을 요구하게 됩니다.
KakaoTalk_Photo_2021-10-06-14-30-08

RoBERTA 계열은 제가 알기로는 token_type_ids를 받지 않는 걸로 알고 있는데, 해당 부분에서 에러를 발생시키는 것 같습니다.

tokenizer에 return_token_type_ids = False argument를 넣어주지 않는다면, trainer에서 돌렸을 때 다음 134번 줄과 같이 token_type_ids embedding을 요구하게 됩니다. KakaoTalk_Photo_2021-10-06-14-30-08

RoBERTA 계열은 제가 알기로는 token_type_ids를 받지 않는 걸로 알고 있는데, 해당 부분에서 에러를 발생시키는 것 같습니다.

헉 좋은 답변 감사합니다!! 혹시 허깅페이스가 아닌 그냥 파이토치 스타일로 학습을 돌리는 것은 에러와 무관할까요?!

@howsmyanimeprofilepicture
제가 사용한 trainer 코드에서는 앞서 정의한 tokenizer에서 return_token_type_ids = False만 해놓으면 그 이후로는 동일하게 작성했습니다.

다만 model.forward()에서 token_type_ids mask를 input에서 정의하면 안 되고, 마찬가지로 model의 logits output에서 token_type_ids mask를 요구해서는 안 됩니다 ㅎㅎ

@snoop2head 선생님 말씀처럼!! 하니까 에러가 말끔하게 해결되었습니다 :D 정말 감사합니다 ><

더 좋은 방법은...
AutoTokenizer.from_pretrained(model_name, model_input_names = ["input_ids", "attention_mask"])
이렇게 tokenizer를 불러들일 때 설정을 해버리면 됩니다!
그러면 training, inference 코드를 수정할 필요 없이 모델에 관계없이 동작하게 됩니다! 실제로도 훨 안정적인 방식 같네요

https://huggingface.co/transformers/model_doc/roberta.html

RoBERTa doesn’t have token_type_ids, you don’t need to indicate which token belongs to which segment. Just separate your segments with the separation token tokenizer.sep_token (or )

@nannullna 좋은 노하우 공유 정말 감사합니다 :D 허깅페이스는 정말 다양하게 옵션을 조정할 수 있어서 좋으면서도 공식문서를 자꾸 끼고 살게 되는 거 같습니다 ㅠㅠ...