본문 바로가기

Docker

Docker로 Diffusion Mamba 학습하기

이전 포스팅에서, docker의 volume을 dataset이 위치하는 assets에만 걸어두었다.

이유는 학습한 모델이 어디에 저장되는지 몰랐기 때문인데, 나중에 볼륨을 추가로 걸어주면 될 테니 큰 걱정은 하고있지 않는다.

추가적으로, docker file에서 root를 걸을 때, root에 기존 file을 모두 copy, 즉

COPY . /root/

을 하는것 보다는,

COPY . /root/DIM/

과 같이 새로운 폴더를 만들어서 한 뒤, 전체 폴더를 volume으로 연결하는 작업을 진행해보고 싶다.

-> 이렇게 하면 전체 코드를 volume과 연결해도 mamba를 잘 로드할 수 있을 것이라고 "추측" 하고 있다.

 

DiM 학습을 진행하면서, 다음과 같은 문제들이 발생했다.

 

문제 1: cannot import name 'cached_download' from 'huggingface_hub'

위 경우는 huggingface_hub가 0.26으로 올라가며 발생하는 문제로, huggingface_hub를 0.25로 내려주니 문제가 사라졌다.

출처: https://github.com/easydiffusion/easydiffusion/issues/1851

 

cannot import name 'cached_download' from 'huggingface_hub' · Issue #1851 · easydiffusion/easydiffusion

Describe the bug cannot import name 'cached_download' from 'huggingface_hub' To Reproduce Steps to reproduce the behavior: Go to '...' Click on '....' Scroll down to '....' See error Expected behav...

github.com

문제 2: RuntimeError: CUDA error

발생한 문제의 전문은 다음과 같다.

RuntimeError: CUDA error: invalid device ordinal
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

GPT에 질의해본 결과, accelerate에서 --multi_gpu --num_processes 8 과 같이 다중 GPU 사용을 허용해서 그렇다는 답변을 받았다.

# 이전에 실행했던 명령어
accelerate launch --multi_gpu --num_processes 8 --mixed_precision fp16 ./train.py --config=configs/cifar10_S_DiM.py

현재 본인은 A6000 단일 GPU를 사용하고 있기 때문에, 위와 같이 다중 GPU를 사용하겠다고 하면 문제가 발생하는 것이었다.

# 수정된 명령어
accelerate launch --mixed_precision fp16 ./train.py --config=configs/cifar10_S_DiM.py

아래와 같이 수정한 결과, 학습이 잘 진행되는 것을 볼 수 있었다!

향후 목표로는 docker 환경 재설정을 통해 파일을 docker 외부에서 수정해도 내부로 잘 연결되도록 할 것이고,

한번에 학습을 진행할 수 있도록 docker 환경을 더욱 명확히 세팅하고자 한다.

'Docker' 카테고리의 다른 글

Docker Volume 연결하기  (0) 2024.12.09
Docker로 Mamba 시작하기  (0) 2024.12.03