boostcampaitech5 / level2_klue-nlp-04

level2_klue-nlp-04 created by GitHub Classroom
1 stars 0 forks source link

[Model] 속도가 너무 느리다 #7

Closed lig96 closed 1 year ago

lig96 commented 1 year ago

문제점

속도가 느리다

해결 방법

  training_args = TrainingArguments(
    fp16=True,
    gradient_checkpointing=True,

    output_dir='./results',          # output directory
    save_total_limit=5,              # number of total save model.
    save_steps=500,                 # model saving step.
    ##등등등
    #배치 사이즈도 추가로 키워줄 수 있다.

맨 위에 2줄만 추가하면 된다.

결과

가나다라 Time: 500.35 Samples/second: 64.89 GPU memory occupied: 3867 MB. 마바사아 roberta-small, epoch1

가나다라 Time: 231.83 Samples/second: 140.06 GPU memory occupied: 3249 MB. 마바사아 roberta-small, epoch1, fp16

가나다라 16.23it/s 73.80it/s Time: 255.37 Samples/second: 127.15 GPU memory occupied: 2421 MB. 마바사아 roberta-small, epoch1, fp16, grad체크포인트

가나다라 4.75it/s Time: 983.47 Samples/second: 33.02 GPU memory occupied: 6145 MB. 마바사아 bert-base, epoch1

가나다라 8.4it/s Time: 477.89 Samples/second: 67.94 GPU memory occupied: 3085 MB. 마바사아 bert-base, epoch1, fp16, grad체크포인트

으로 속도도 빨라지고 메모리도(=배치 사이즈 늘릴 여력 있음) 줄어든다. bert-base 기준 속도 2배, 메모리 1/2배.

lig96 commented 1 year ago

리뷰 해주시면 ㅗ딥니ㅏ

lig96 commented 1 year ago

추가로 할 수 있는 것 adamw 대신 adafactor, 8비트아담 데이터로더 pin과 nun_worker 설정하기 배치 크기 늘리기

dbsrlskfdk commented 1 year ago

https://huggingface.co/docs/transformers/v4.18.0/en/performance