티스토리 뷰

(VllmWorkerProcess pid=0) ERROR 07-25 09:33:19 multiproc_worker_utils.py:242] RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

 

vllm을 통해 모델 추론을 하려고 하는데, 위와 같은 에러가 발생했다.

 

https://github.com/vllm-project/vllm/issues/8893

 

[Bug]: RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn'

I have updated to the latest version and used the “spawn” method, export VLLM_WORKER_MULTIPROC_METHOD=spawn but the error still persists. Could you please help me?

github.com

위 링크에 따르면, 해결 방법은 크게 2가지로 나뉜다.

 

해결 방법:

import os

os.environ['VLLM_WORKER_MULTIPROC_METHOD'] = 'spawn'

1. 위 코드를 추가한다.

2. 실행하려는 py 파일에서 vLLM 호출 코드를 if __name__ == "__main__": 구문 안에 작성한다.

 

위 방법을 수행하니 에러가 해결되었다.

반응형

댓글