에러 메시지

docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #0: error running hook: exit status 1, stdout: , stderr: Auto-detected mode as 'legacy'
nvidia-container-cli: mount error: file creation failed: /var/lib/docker/overlay2/db95c0c61f0f8c7eb7b9e6aa595c3624f63734322a57f1daa401407c725ab89d/merged/usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1: file exists: unknown.
ERRO[0000] error waiting for container:

문제 상황

pytorch 공식 이미지를 GPU 사용하는 컨테이너로 실행시켰을 때는 잘되는 것을 보아서, 내가 리눅스에서 push한 이미지를 WSL2로 pull하였었는데, 이를 컨테이너로 만들 때 문제가 생겼다.

 

문제 원인

해당 글에서 찾은 내용으로 문제를 해결하였다. WSL2에서 nvidia 관련 드라이버가 포함되는 이미지를 컨테이너에 mount시 기존에 설치된 드라이버와 충돌하는 경우가 있는 것으로 보인다고 한다.

 

도커파일 생성

도커파일 작성은, 도커파일을 둘 디렉토리를 하나 생성한 뒤 그 안에서 만든다.

vi Dockerfile
FROM <docker image name>

RUN rm -rf \
    /usr/lib/x86_64-linux-gnu/libcuda.so* \
    /usr/lib/x86_64-linux-gnu/libnvcuvid.so* \
    /usr/lib/x86_64-linux-gnu/libnvidia-*.so* \
    /usr/lib/firmware \
    /usr/local/cuda/compat/lib

 

도커파일 생성후 build하여 이미지 생성

docker build . -t <image name>

 

컨테이너 생성

 docker run -it --shm-size=256g --gpus all --name diff_js xxxxxx/diffusion:latest /bin/bash

이제 제대로 컨테이너 생성이 된 것을 확인할 수 있다.

 

 

 

 

참고 자료

https://forums.developer.nvidia.com/t/wsl-modulus-docker-run-error-libnvidia-ml-so-1-file-exists-unknown/256058

 

WSL Modulus Docker run error (libnvidia-ml.so.1: file exists: unknown.)

Hi. I’m trying to use Modulus with docker on wsl2 ubuntu20.04 (windows11) And I have a problem. Running docker with below command docker run --gpus all -v ${PWD}/examples:/examples -it --rm nvcr.io/nvidia/modulus/modulus:22.09 bash Then an error like thi

forums.developer.nvidia.com

 

https://blog.nitrolab.kr/archives/965

 

WSL2: nvidia-container-cli mount error, libnvidia-ml.so.1: file exists: unknown – NitroLab

WSL2: nvidia-container-cli mount error, libnvidia-ml.so.1: file exists: unknown by Dr. Nitro · 2023년 04월 06일 관련정보: https://github.com/NVIDIA/nvidia-docker/issues/1551 https://github.com/NVIDIA/nvidia-docker WSL2에서 nvidia 관련 드라이

blog.nitrolab.kr

 

https://forums.docker.com/t/nvidia-cuda-doesnt-work-on-docker-desktop-but-works-on-docker-engine/130668

 

Nvidia/cuda doesn't work on Docker Desktop but works on Docker Engine

Hi. I’m trying to comb through the forum, documentation and google search but none of the things I’ve read solved my problem so far. Issue “docker run --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi” on Docker Desktop gives the following

forums.docker.com