์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

Docker ๋น ๋ฅธ ์‹œ์ž‘ ๊ฐ€์ด๋“œ Ultralytics

Ultralytics ๋„์ปค ํŒจํ‚ค์ง€ ๋น„์ฃผ์–ผ

์ด ๊ฐ€์ด๋“œ๋Š” Ultralytics ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•œ Docker ํ™˜๊ฒฝ ์„ค์ •์— ๋Œ€ํ•œ ํฌ๊ด„์ ์ธ ์†Œ๊ฐœ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. Docker๋Š” ์ปจํ…Œ์ด๋„ˆ์—์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœ, ๋ฐฐํฌ ๋ฐ ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ํ”Œ๋žซํผ์ž…๋‹ˆ๋‹ค. ํŠนํžˆ ์†Œํ”„ํŠธ์›จ์–ด๊ฐ€ ๋ฐฐํฌ๋œ ์œ„์น˜์— ๊ด€๊ณ„์—†์ด ํ•ญ์ƒ ๋™์ผํ•˜๊ฒŒ ์‹คํ–‰๋˜๋„๋ก ํ•˜๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Ultralytics Docker ๋ฆฌํฌ์ง€ํ† ๋ฆฌ( Hub )๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

๋„์ปค ํ’€

ํ•™์Šต ๋‚ด์šฉ

  • NVIDIA ์ง€์›์œผ๋กœ Docker ์„ค์ •ํ•˜๊ธฐ
  • Ultralytics ๋„์ปค ์ด๋ฏธ์ง€ ์„ค์น˜
  • ๋„์ปค ์ปจํ…Œ์ด๋„ˆ์—์„œ Ultralytics ์‹คํ–‰
  • ์ปจํ…Œ์ด๋„ˆ์— ๋กœ์ปฌ ๋””๋ ‰ํ† ๋ฆฌ ๋งˆ์šดํŠธ

์ „์ œ ์กฐ๊ฑด

  • ์‹œ์Šคํ…œ์— Docker๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ Docker ์›น์‚ฌ์ดํŠธ์—์„œ ๋‹ค์šด๋กœ๋“œํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์‹œ์Šคํ…œ์— NVIDIA GPU๊ฐ€ ์žˆ๊ณ  NVIDIA ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

NVIDIA ์ง€์›์œผ๋กœ Docker ์„ค์ •ํ•˜๊ธฐ

๋จผ์ € NVIDIA ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์ œ๋Œ€๋กœ ์„ค์น˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค:

nvidia-smi

NVIDIA ๋„์ปค ๋Ÿฐํƒ€์ž„ ์„ค์น˜

์ด์ œ Docker ์ปจํ…Œ์ด๋„ˆ์—์„œ GPU ์ง€์›์„ ํ™œ์„ฑํ™”ํ•˜๊ธฐ ์œ„ํ•ด NVIDIA Docker ๋Ÿฐํƒ€์ž„์„ ์„ค์น˜ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค:

# Add NVIDIA package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(lsb_release -cs)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

# Install NVIDIA Docker runtime
sudo apt-get update
sudo apt-get install -y nvidia-docker2

# Restart Docker service to apply changes
sudo systemctl restart docker

๋„์ปค๋กœ NVIDIA ๋Ÿฐํƒ€์ž„ ํ™•์ธ

์‹คํ–‰ docker info | grep -i runtime ์„ ์‚ฌ์šฉํ•˜์—ฌ nvidia ๊ฐ€ ๋Ÿฐํƒ€์ž„ ๋ชฉ๋ก์— ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค:

docker info | grep -i runtime

Ultralytics ๋„์ปค ์ด๋ฏธ์ง€ ์„ค์น˜

Ultralytics ๋Š” ๋‹ค์–‘ํ•œ ํ”Œ๋žซํผ๊ณผ ์‚ฌ์šฉ ์‚ฌ๋ก€์— ์ตœ์ ํ™”๋œ ์—ฌ๋Ÿฌ Docker ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

  • ๋„์ปคํŒŒ์ผ: ๊ต์œก์— ์ด์ƒ์ ์ธ GPU ์ด๋ฏธ์ง€.
  • ๋„์ปคํŒŒ์ผ-arm64: ARM64 ์•„ํ‚คํ…์ฒ˜์˜ ๊ฒฝ์šฐ, ๋ผ์ฆˆ๋ฒ ๋ฆฌ ํŒŒ์ด์™€ ๊ฐ™์€ ์žฅ์น˜์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.
  • Dockerfile-cpu: ์ถ”๋ก  ๋ฐ ๋น„ GPU ํ™˜๊ฒฝ์„ ์œ„ํ•œ CPU ์ „์šฉ ๋ฒ„์ „์ž…๋‹ˆ๋‹ค.
  • ๋„์ปคํŒŒ์ผ-์ ฏ์Šจ: NVIDIA Jetson ์žฅ์น˜์— ์ตœ์ ํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
  • ๋„์ปคํŒŒ์ผ-python: ๊ฒฝ๋Ÿ‰ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์œ„ํ•œ ์ตœ์†Œํ•œ์˜ Python ํ™˜๊ฒฝ.
  • ๋„์ปคํŒŒ์ผ-์ฝ˜๋‹ค: ์ฝ˜๋‹ค๋ฅผ ํ†ตํ•ด ์„ค์น˜๋œ ๋ฏธ๋‹ˆ์ฝ˜๋‹ค3 ๋ฐ Ultralytics ํŒจํ‚ค์ง€๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

์ตœ์‹  ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค:

# Set image name as a variable
t=ultralytics/ultralytics:latest

# Pull the latest Ultralytics image from Docker Hub
sudo docker pull $t

๋„์ปค ์ปจํ…Œ์ด๋„ˆ์—์„œ Ultralytics ์‹คํ–‰

Ultralytics ๋„์ปค ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

# Run with all GPUs
sudo docker run -it --ipc=host --gpus all $t

# Run specifying which GPUs to use
sudo docker run -it --ipc=host --gpus '"device=2,3"' $t

The -it ํ”Œ๋ž˜๊ทธ๋Š” ์˜์‚ฌ TTY๋ฅผ ํ• ๋‹นํ•˜๊ณ  stdin์„ ์—ด์–ด๋‘์–ด ์ปจํ…Œ์ด๋„ˆ์™€ ์ƒํ˜ธ์ž‘์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์˜ --ipc=host ํ”Œ๋ž˜๊ทธ๋Š” ํ”„๋กœ์„ธ์Šค ๊ฐ„ ๋ฉ”๋ชจ๋ฆฌ ๊ณต์œ ์— ํ•„์ˆ˜์ ์ธ ํ˜ธ์ŠคํŠธ์˜ IPC ๋„ค์ž„์ŠคํŽ˜์ด์Šค ๊ณต์œ ๋ฅผ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค. ํ˜ธ์ŠคํŠธ์˜ --gpus ํ”Œ๋ž˜๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ํ˜ธ์ŠคํŠธ์˜ GPU์— ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํŒŒ์ผ ์ ‘๊ทผ์„ฑ ๊ด€๋ จ ์ฐธ๊ณ  ์‚ฌํ•ญ

์ปจํ…Œ์ด๋„ˆ ๋‚ด์—์„œ ๋กœ์ปฌ ์ปดํ“จํ„ฐ์˜ ํŒŒ์ผ๋กœ ์ž‘์—…ํ•˜๋ ค๋ฉด Docker ๋ณผ๋ฅจ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

# Mount a local directory into the container
sudo docker run -it --ipc=host --gpus all -v /path/on/host:/path/in/container $t

๋ฐ”๊พธ๊ธฐ /path/on/host ๋ฅผ ๋กœ์ปฌ ์ปดํ“จํ„ฐ์˜ ๋””๋ ‰ํ„ฐ๋ฆฌ ๊ฒฝ๋กœ์™€ /path/in/container ๋ฅผ Docker ์ปจํ…Œ์ด๋„ˆ ๋‚ด๋ถ€์˜ ์›ํ•˜๋Š” ๊ฒฝ๋กœ๋กœ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.


์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ์ด์ œ Docker์—์„œ Ultralytics ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •๋˜์—ˆ์œผ๋ฉฐ ๊ฐ•๋ ฅํ•œ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์„ค์น˜ ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๋ ค๋ฉด Ultralytics ๋น ๋ฅธ ์‹œ์ž‘ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.



์ƒ์„ฑ๋จ 2023-11-12, ์—…๋ฐ์ดํŠธ๋จ 2023-11-16
์ž‘์„ฑ์ž: glenn-jocher (2)

๋Œ“๊ธ€