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

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

Ultralytics ์ฝ˜๋‹ค ํŒจํ‚ค์ง€ ๋น„์ฃผ์–ผ

์ด ๊ฐ€์ด๋“œ๋Š” Ultralytics ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•œ Conda ํ™˜๊ฒฝ ์„ค์ •์— ๋Œ€ํ•œ ํฌ๊ด„์ ์ธ ์†Œ๊ฐœ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. Conda๋Š” ์˜คํ”ˆ ์†Œ์Šค ํŒจํ‚ค์ง€ ๋ฐ ํ™˜๊ฒฝ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์œผ๋กœ, ํŒจํ‚ค์ง€ ๋ฐ ์ข…์† ์š”์†Œ๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐ ์žˆ์–ด pip์˜ ํ›Œ๋ฅญํ•œ ๋Œ€์•ˆ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๋…๋ฆฝ๋œ ํ™˜๊ฒฝ์œผ๋กœ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๋จธ์‹  ๋Ÿฌ๋‹ ์ž‘์—…์— ํŠนํžˆ ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Anaconda์˜ Ultralytics Conda ํŒจํ‚ค์ง€๋ฅผ ๋ฐฉ๋ฌธํ•˜๊ณ  GitHub์—์„œ ํŒจํ‚ค์ง€ ์—…๋ฐ์ดํŠธ๋ฅผ ์œ„ํ•œ Ultralytics ํ”ผ๋“œ์Šคํ†ก ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

์ฝ˜๋‹ค ๋ฒ„์ „ ์ฝ˜๋‹ค ๋‹ค์šด๋กœ๋“œ ์ฝ˜๋‹ค ๋ ˆ์‹œํ”ผ ์ฝ˜๋‹ค ํ”Œ๋žซํผ

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

  • Conda ํ™˜๊ฒฝ ์„ค์ •
  • Conda๋ฅผ ํ†ตํ•ด Ultralytics ์„ค์น˜
  • ์‚ฌ์šฉ์ž ํ™˜๊ฒฝ์—์„œ Ultralytics ์ดˆ๊ธฐํ™”ํ•˜๊ธฐ
  • Conda์™€ ํ•จ๊ป˜ Ultralytics Docker ์ด๋ฏธ์ง€ ์‚ฌ์šฉ

์ „์ œ ์กฐ๊ฑด

  • ์‹œ์Šคํ…œ์— Anaconda ๋˜๋Š” Miniconda๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š์€ ๊ฒฝ์šฐ Anaconda ๋˜๋Š” Miniconda์—์„œ ๋‹ค์šด๋กœ๋“œํ•˜์—ฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

Conda ํ™˜๊ฒฝ ์„ค์ •

๋จผ์ € ์ƒˆ Conda ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ํ„ฐ๋ฏธ๋„์„ ์—ด๊ณ  ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

conda create --name ultralytics-env python=3.11 -y

์ƒˆ ํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค:

conda activate ultralytics-env

์„ค์น˜ Ultralytics

Ultralytics ํŒจํ‚ค์ง€๋Š” conda-forge ์ฑ„๋„์—์„œ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

conda install -c conda-forge ultralytics

์ฐธ๊ณ  ์‚ฌํ•ญ CUDA ํ™˜๊ฒฝ

CUDA- ์ง€์› ํ™˜๊ฒฝ์—์„œ ์ž‘์—…ํ•˜๋Š” ๊ฒฝ์šฐ ๋‹ค์Œ์„ ์„ค์น˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ultralytics, pytorch๋ฐ pytorch-cuda ๊ฐˆ๋“ฑ์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ํ•จ๊ป˜ ๋…ธ๋ ฅํ•ฉ๋‹ˆ๋‹ค:

conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=11.8 ultralytics

์‚ฌ์šฉ Ultralytics

Ultralytics ์„ ์„ค์น˜ํ•˜๋ฉด ์ด์ œ ๊ฐœ์ฒด ๊ฐ์ง€, ์ธ์Šคํ„ด์Šค ์„ธ๋ถ„ํ™” ๋“ฑ์„ ์œ„ํ•œ ๊ฐ•๋ ฅํ•œ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ด๋ฏธ์ง€๋ฅผ ์˜ˆ์ธกํ•˜๊ธฐ ์œ„ํ•ด ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

from ultralytics import YOLO

model = YOLO("yolo11n.pt")  # initialize model
results = model("path/to/image.jpg")  # perform inference
results[0].show()  # display results for the first image

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

Docker๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ์„ ํ˜ธํ•˜๋Š” ๊ฒฝ์šฐ Ultralytics ์—์„œ Conda ํ™˜๊ฒฝ์ด ํฌํ•จ๋œ Docker ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ด๋ฏธ์ง€๋Š” DockerHub์—์„œ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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

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

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

์ด๋ฏธ์ง€๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค:

# Run the Ultralytics image in a container with GPU support
sudo docker run -it --ipc=host --gpus all $t  # all GPUs
sudo docker run -it --ipc=host --gpus '"device=2,3"' $t  # specify GPUs

Libmamba๋กœ ์„ค์น˜ ์†๋„ ํ–ฅ์ƒ

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ฒฝ์šฐ ํŒจํ‚ค์ง€ ์„ค์น˜ ์†๋„ ํ–ฅ์ƒ ํ”„๋กœ์„ธ์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์„ ํƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. libmamba๋Š” ๋น ๋ฅด๊ณ  ํฌ๋กœ์Šค ํ”Œ๋žซํผ์ด๋ฉฐ ์ข…์†์„ฑ์„ ์ธ์‹ํ•˜๋Š” ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ์ž๋กœ, Conda์˜ ๊ธฐ๋ณธ๊ฐ’์„ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ๋Š” ํ•ด๊ฒฐ์‚ฌ ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

Libmamba๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋Š” ๋ฐฉ๋ฒ•

์‚ฌ์šฉํ•˜๋ ค๋ฉด libmamba ๋ฅผ Conda์˜ ์†”๋ฒ„๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋ฅผ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  1. ๋จผ์ € conda-libmamba-solver ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. Conda ๋ฒ„์ „์ด 4.11 ์ด์ƒ์ธ ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ด ๋‹จ๊ณ„๋ฅผ ๊ฑด๋„ˆ๋›ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. libmamba ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

    conda install conda-libmamba-solver
    
  2. ๋‹ค์Œ์œผ๋กœ ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜๋„๋ก Conda๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. libmamba ๋ฅผ ํ•ด๊ฒฐ์‚ฌ๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:

    conda config --set solver libmamba
    

์—ฌ๊ธฐ๊นŒ์ง€์ž…๋‹ˆ๋‹ค! ์ด์ œ Conda ์„ค์น˜๋Š” ๋‹ค์Œ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. libmamba ๋ฅผ ์†”๋ฒ„๋กœ ์‚ฌ์šฉํ•˜๋ฉด ํŒจํ‚ค์ง€ ์„ค์น˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋” ๋นจ๋ผ์ง‘๋‹ˆ๋‹ค.


์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ์ด์ œ ์ฝ˜๋‹ค ํ™˜๊ฒฝ์„ ์„ฑ๊ณต์ ์œผ๋กœ ์„ค์ •ํ•˜๊ณ  Ultralytics ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ–ˆ์œผ๋ฉฐ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ์„ ์‚ดํŽด๋ณผ ์ค€๋น„๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. Ultralytics ๋ฌธ์„œ์—์„œ ๊ณ ๊ธ‰ ํŠœํ† ๋ฆฌ์–ผ๊ณผ ์˜ˆ์ œ๋ฅผ ์ž์„ธํžˆ ์‚ดํŽด๋ณด์„ธ์š”.

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

Ultralytics ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•œ Conda ํ™˜๊ฒฝ ์„ค์ • ์ ˆ์ฐจ๋Š” ์–ด๋–ป๊ฒŒ ๋˜๋‚˜์š”?

Ultralytics ํ”„๋กœ์ ํŠธ๋ฅผ ์œ„ํ•œ Conda ํ™˜๊ฒฝ ์„ค์ •์€ ๊ฐ„๋‹จํ•˜๋ฉฐ ์›ํ™œํ•œ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๋ฅผ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. ๋จผ์ € ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ Conda ํ™˜๊ฒฝ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค:

conda create --name ultralytics-env python=3.11 -y

๊ทธ๋Ÿฐ ๋‹ค์Œ ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ ํ™˜๊ฒฝ์„ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค:

conda activate ultralytics-env

๋งˆ์ง€๋ง‰์œผ๋กœ ์ฝ˜๋‹ค-ํฌ์ง€ ์ฑ„๋„์—์„œ Ultralytics ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค:

conda install -c conda-forge ultralytics

Ultralytics ํ”„๋กœ์ ํŠธ์—์„œ ์ข…์†์„ฑ์„ ๊ด€๋ฆฌํ•  ๋•Œ pip๋ณด๋‹ค Conda๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?

Conda๋Š” ๊ฐ•๋ ฅํ•œ ํŒจํ‚ค์ง€ ๋ฐ ํ™˜๊ฒฝ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์œผ๋กœ pip์— ๋น„ํ•ด ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์žฅ์ ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ข…์†์„ฑ์„ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ํ•„์š”ํ•œ ๋ชจ๋“  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ˜ธํ™˜๋˜๋„๋ก ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. Conda์˜ ๊ฒฉ๋ฆฌ๋œ ํ™˜๊ฒฝ์€ ๋ฐ์ดํ„ฐ ๊ณผํ•™ ๋ฐ ๋จธ์‹  ๋Ÿฌ๋‹ ํ”„๋กœ์ ํŠธ์—์„œ ๋งค์šฐ ์ค‘์š”ํ•œ ํŒจํ‚ค์ง€ ๊ฐ„์˜ ์ถฉ๋Œ์„ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ, Conda๋Š” ๋ฐ”์ด๋„ˆ๋ฆฌ ํŒจํ‚ค์ง€ ๋ฐฐํฌ๋ฅผ ์ง€์›ํ•˜์—ฌ ์„ค์น˜ ํ”„๋กœ์„ธ์Šค์˜ ์†๋„๋ฅผ ๋†’์ž…๋‹ˆ๋‹ค.

๋” ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ์œ„ํ•ด CUDA ์ง€์› ํ™˜๊ฒฝ์—์„œ Ultralytics YOLO ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

์˜ˆ, CUDA ์ง€์› ํ™˜๊ฒฝ์„ ํ™œ์šฉํ•˜์—ฌ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์„ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ultralytics, pytorch๋ฐ pytorch-cuda ๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜์—ฌ ์ถฉ๋Œ์„ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค:

conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision pytorch-cuda=11.8 ultralytics

์ด ์„ค์ •์„ ํ†ตํ•ด ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ ํ›ˆ๋ จ ๋ฐ ์ถ”๋ก ๊ณผ ๊ฐ™์€ ์ง‘์ค‘์ ์ธ ์ž‘์—…์— ํ•„์ˆ˜์ ์ธ GPU ๊ฐ€์†์„ ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Ultralytics ์„ค์น˜ ๊ฐ€์ด๋“œ๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

Conda ํ™˜๊ฒฝ์—์„œ Ultralytics Docker ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์–ด๋–ค ์ด์ ์ด ์žˆ๋‚˜์š”?

Ultralytics ๋„์ปค ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ผ๊ด€๋˜๊ณ  ์žฌํ˜„ ๊ฐ€๋Šฅํ•œ ํ™˜๊ฒฝ์„ ๋ณด์žฅํ•˜์—ฌ "๋‚ด ์ปดํ“จํ„ฐ์—์„œ ์ž‘๋™ํ•œ๋‹ค"๋Š” ๋ฌธ์ œ๋ฅผ ์—†์•จ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์ด๋ฏธ์ง€์—๋Š” ์‚ฌ์ „ ๊ตฌ์„ฑ๋œ Conda ํ™˜๊ฒฝ์ด ํฌํ•จ๋˜์–ด ์žˆ์–ด ์„ค์ • ํ”„๋กœ์„ธ์Šค๊ฐ€ ๊ฐ„์†Œํ™”๋ฉ๋‹ˆ๋‹ค. ๋‹ค์Œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•˜์—ฌ ์ตœ์‹  Ultralytics Docker ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ ธ์™€ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

sudo docker pull ultralytics/ultralytics:latest-conda
sudo docker run -it --ipc=host --gpus all ultralytics/ultralytics:latest-conda

์ด ์ ‘๊ทผ ๋ฐฉ์‹์€ ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•˜๊ฑฐ๋‚˜ ์ˆ˜๋™ ๊ตฌ์„ฑ ์—†์ด ๋ณต์žกํ•œ ์›Œํฌํ”Œ๋กœ๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐ ์ด์ƒ์ ์ž…๋‹ˆ๋‹ค. ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ Ultralytics Conda Docker Image.

Ultralytics ํ™˜๊ฒฝ์—์„œ Conda ํŒจํ‚ค์ง€ ์„ค์น˜ ์†๋„๋ฅผ ๋†’์ด๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ํŒจํ‚ค์ง€ ์„ค์น˜ ํ”„๋กœ์„ธ์Šค์˜ ์†๋„๋ฅผ ๋†’์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. libmamba์˜ ๋น ๋ฅธ ์ข…์†์„ฑ ํ•ด๊ฒฐ์‚ฌ ์ž…๋‹ˆ๋‹ค. ๋จผ์ € conda-libmamba-solver ํŒจํ‚ค์ง€์ž…๋‹ˆ๋‹ค:

conda install conda-libmamba-solver

๊ทธ๋Ÿฐ ๋‹ค์Œ ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜๋„๋ก Conda๋ฅผ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. libmamba ๋ฅผ ํ•ด๊ฒฐ์‚ฌ๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค:

conda config --set solver libmamba

์ด ์„ค์ •์€ ๋” ๋น ๋ฅด๊ณ  ํšจ์œจ์ ์ธ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ํ™˜๊ฒฝ ์ตœ์ ํ™”์— ๋Œ€ํ•œ ์ž์„ธํ•œ ํŒ์€ libmamba ์„ค์น˜์— ๋Œ€ํ•œ ๋„์›€๋ง์„ ์ฐธ์กฐํ•˜์„ธ์š”.

๐Ÿ“…1 ๋…„ ์ „ ์ƒ์„ฑ๋จ โœ๏ธ 1๊ฐœ์›” ์ „ ์—…๋ฐ์ดํŠธ๋จ

๋Œ“๊ธ€