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

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

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

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

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

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

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

์ „์ œ ์กฐ๊ฑด

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

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

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

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

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

conda activate ultralytics-env

์„ค์น˜ Ultralytics

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

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('yolov8n.pt')  # initialize model
results = model('path/to/image.jpg')  # perform inference
results.show()  # display results

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

๋ฌผ๋ก  Conda ๊ฐ€์ด๋“œ์— ๋‹ค์Œ ์„น์…˜์„ ํฌํ•จํ•˜์—ฌ ์‚ฌ์šฉ์ž์—๊ฒŒ ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ค์น˜ ์†๋„๋ฅผ ๋†’์ด๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•ˆ๋‚ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. libmamba:


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

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

๋ฆฌ๋ธŒ๋ง˜๋ฐ” ํ™œ์„ฑํ™” ๋ฐฉ๋ฒ•

์‚ฌ์šฉํ•˜๋ ค๋ฉด 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 ๋ฅผ ์†”๋ฒ„๋กœ ์‚ฌ์šฉํ•˜๋ฉด ํŒจํ‚ค์ง€ ์„ค์น˜ ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋” ๋นจ๋ผ์ง‘๋‹ˆ๋‹ค.


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



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

๋Œ“๊ธ€