"RuntimeError: DataLoader worker (pid 17362) is killed by signal: Bus error. It is possible that dataloader's workers are out of shared memory. Please try to raise your shared memory limit."
Docker Container 실행 환경 내에서, 어떤 구현 논문의 test를 진행하느 과정에서 위와같은 에러를 마주함.
꽤 자주 발생하는 듯 하여서, 찾아본 결과 도커로 컨테이너를 생성하게 되면 호스트와 컨테이너는 공유하는 메모리 공간이 생기게 되는데 이 공간에 여유가 없어서 발생되는 에러* 라고 한다.
실제로 실시간 메모리 사용량을 지켜보았는데 --shm-size 옵션을 2G로 주었는데도, 2G너머로 치솟을듯하며 해당에러가 발생하는 것을 확인하였다.
결국, 검색하여 얻어낸 해결 방법은 총 두가지이다. (자세한 내용은 아래 원본 링크 참조)
1) Docker container 실행 시, "--shm-size" 옵션 추가로 충분히 넉넉한 메모리 공유*
그런데 1)은 이해가 되는데, 2)는 사실 잘 이해가 안되어 찾아보았다.
(자세한 내용은 아래 ref 참조 )
- ipc란?***,****, *****
리눅스 커널 구조를 예를 들어보면,
process는 완전히 독립된 실행객체이다. (독립-> 다른 프로세스의 영향을 받지않는다)
하지만, 독립되어있다보니 서로 처리한 정보 공유등의 통신에는 어려움이 생긴다.
이러한 문제의 해결 & 여러 프로세스가 수행해서 빠른 성능 향상 목적으로,
커널 영역에서 IPC라는 내부프로세스간 통신(Inter Process Communication)을 제공하여 프로세스간 통신을 가능하게함.
이때, 데이터를 공유하는 방법에는 크게 1) 통신을 활용한 데이터 교환 2) 데이터를 아예 직접 공유, 함께 사용하는 것 으로 나뉨.
1)의 예시로 PIPE, NamedPIPE 등의 방법들이 있는데, 2)로는 바로 Shared Memory (공유메모리) 가 있다.
공유 메모리는 중개자가 없이 곧바로 메모리 접근이 가능하여, 모든 IPC중 가장 바르게 작동 가능하
그렇다면, Docker 공식 사이트에서의 정의를 살펴보면 --ipc setting 부분에서,
"IPC (POSIX/SysV IPC) namespace provides separation of named shared memory segments, semaphores and message queues." 라고 한다.
완벽히 이해는 잘 되지 않지만, 어쨌든 host의 공간을 공유해줘라 라는 의미로 사용을 한다고 희미하게 이해한 상황!
혹시 이 부분에 대해 구체적으로 아시는 분이 계시면 지식 공유 부탁드리겠습니다ㅎㅎ
( Reference )
* https://jybaek.tistory.com/785
** https://curioso365.tistory.com/136
*** https://docs.docker.com/engine/reference/run/#ipc-settings---ipc
**** https://jwprogramming.tistory.com/54
***** https://velog.io/@redgem92/%EC%9A%B4%EC%98%81%EC%B2%B4%EC%A0%9C-IPC-%EA%B8%B0%EB%B2%95