Bugfix : Prompt Inference 실행시, 모델의 device setting이 flag와 맞지 않는 버그 해결#26
Open
Se-Hun wants to merge 1 commit intokakaobrain:mainfrom
Open
Bugfix : Prompt Inference 실행시, 모델의 device setting이 flag와 맞지 않는 버그 해결#26Se-Hun wants to merge 1 commit intokakaobrain:mainfrom
Se-Hun wants to merge 1 commit intokakaobrain:mainfrom
Conversation
cosine0
suggested changes
Feb 20, 2023
Contributor
There was a problem hiding this comment.
Single GPU를 고려하지 않은 저의 실수네요.
이 부분에 분기를 넣은 것은 self.model.to(device) 할 때 메모리가 터질 수 있을 것을 염려해서 self.model.parallelize()로 처음부터 여러 디바이스에 나눠서 올리려 한 것이었습니다.
@Se-Hun 님 말씀대로 이 문제를 해결할 때 모델 선언에서 .to(device)하는 대신 뒷부분에서 깔끔하게
if model_parallel:
self.model.parallelize()
else:
self.model.to(device)이렇게 하거나, CPU 사용시 model_parallelize가 불가능한 점을 반영하여
if self.device != 'cpu' and model_parallelize:
self.model.parallelize()
else:
self.model.to(device)이렇게 하면 좋을 것 같습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
버그 발생 상황
GPU 환경에서 기존의 코드를 동작시킬 때 아래와 같은 에러가 발생합니다.
해결 방법
위의 에러가 발생하는 원인은
KoGPTInference클래스의 생성자가 호출될 때 입력 받은device변수를 통해 GPT 모델의 device가 설정되지 않아 발생하는 문제로 보입니다.따라서, 아래와 같은 코드를 추가하여 문제를 해결하였습니다.