미누에요

[LLM] NotImplementedError: Cannot copy out of meta tensor; no data! 본문

우당탕탕개발기록

[LLM] NotImplementedError: Cannot copy out of meta tensor; no data!

미누라니까요 2025. 4. 13. 15:50
728x90
반응형
SMALL

LLM 파인튜닝을 하던 중 아래와 같은 에러를 맞이했다.

NotImplementedError: Cannot copy out of meta tensor; no data!

 

왜 이런 에러가 뜨는지 몰라서, 구글링을 했다. 

코드 상으로 문제는 없었다. 그래서 더 의문이었다.

 

https://stackoverflow.com/questions/77547377/notimplementederror-cannot-copy-out-of-meta-tensor-no-data

 

NotImplementedError: Cannot copy out of meta tensor; no data

base_model = AutoModelForCausalLM.from_pretrained( 'meta-llama/Llama-2-7b-chat-hf', token=access_token, trust_remote_code=True, device_map="auto", torch_dtype=torch.

stackoverflow.com

 

그러다 stack-overflow에 있는 한 글을 봤는데, 메모리 오류 문제일 수 있다는 것이다!!

감사해요 Miller 씨...

 

그래서 colab에 있는 메모리 현황을 봤더니...............역시 15GB 중에 14GB나 찼다니....

 

그래서 런타임을 해제하고 정리한 후에 다시 실행했는데, 여전히 메모리가 가득 차서 모델 사이즈가 너무 크다고 판단했다.

 

 

그리고 한가지 더 문제점을 발견했는데, 

난 지금 Llama3-8B 모델을 사용 중인데, 모델을 불러올 때 load_in_4bit = False로 설정해둔 것이다.........!!!!

 

여기서 loab_in_4bit는 모델을 4bit 정밀도로 불러와서 메모리 사용을 크게 줄이고, 속도도 개선할 수 있도록 도와주는 옵션.

 

따라서 이 옵션을 True로 변경하고, 추가적으로 colab의 다른 GPU 옵션으로 변경하였다.

(아마 True로만 변경해도 될거임)

 

ㅎㅎ..

 

 

암튼, 다른 triton 모듈 호환성 문제가 아니라 GPU 메모리 VRAM 문제라서 정말 다행이다 ^_^

 

혹시 다른 triton 문제가 발생한다면, Windows 환경 말고 linux나 Google colab 환경에서 해보시길...

728x90
반응형
LIST