Conda로 Ultralytics YOLO 설치하는 방법
이 가이드에서는 Ultralytics 프로젝트를 위한 Conda 환경 설정 방법을 설명합니다. Conda는 오픈 소스 패키지 및 환경 관리 시스템으로, 패키지와 종속성을 설치할 때 pip의 대안으로 사용할 수 있습니다. 격리된 환경을 제공하므로 데이터 과학 및 머신러닝 작업에 특히 적합합니다.
이 가이드에서는 Ultralytics 환경을 만드는 방법, 추론 실행 방법, Conda Docker 이미지 사용 방법, libmamba로 설치 속도를 높이는 방법을 다룹니다.
사전 요구 사항#
시스템에 Anaconda 또는 Miniconda가 설치되어 있어야 합니다. 설치되어 있지 않다면 Anaconda 또는 Miniconda에서 다운로드해 설치하세요.
Ultralytics 설치#
conda-forge 채널에서 Ultralytics를 사용해 새 Conda 환경을 만든 다음 활성화합니다. conda가 현재 호환되는 버전을 함께 확인할 수 있도록 같은 명령에서 Python, Ultralytics, torchvision(conda-forge 패키지의 종속 항목이 아님)을 설치합니다:
conda create --name ultralytics-env -c conda-forge python=3.11 ultralytics torchvision -y
conda activate ultralytics-envCUDA를 지원하는 환경에서 작업하는 경우, conda가 CUDA를 지원하는 PyTorch 빌드를 확인할 수 있도록 같은 명령에 conda-forge의 pytorch-gpu 메타패키지를 추가합니다:
conda create --name ultralytics-env -c conda-forge python=3.11 ultralytics torchvision pytorch-gpu -y
conda activate ultralytics-envROCm 환경에 관한 참고 사항(AMD GPU, Linux)#
ROCm을 사용해 Linux에서 AMD GPU 가속을 이용하는 경우, PyTorch ROCm 휠은 Conda에서 제공되지 않으므로 pip로 설치해야 합니다. 격리를 위해 Conda 환경을 사용한 다음 pip로 PyTorch ROCm과 Ultralytics를 설치하세요:
conda create --name ultralytics-rocm python=3.12 -y
conda activate ultralytics-rocm
pip install "torch[device-all]" "torchvision[device-all]" --index-url https://stable.repo.amd.com/rocm/whl-next/
pip install ultralytics지원되는 ROCm 버전은 PyTorch 시작하기 페이지에서 확인하고, MIGraphX 추론 설정은 AMD GPU 가이드를 참조하세요. 이 설정을 사용하려면 Linux x86_64에서 Python 3.11 이상이 필요합니다.
Ultralytics 사용하기#
Ultralytics를 설치하면 객체 감지, 인스턴스 세그멘테이션 및 기타 비전 작업을 실행할 수 있습니다. 예를 들어 이미지에서 추론을 실행하려면 다음과 같이 합니다.
from ultralytics import YOLO
model = YOLO("yolo26n.pt") # 모델 초기화
results = model("path/to/image.jpg") # 추론 수행
results[0].show() # 첫 번째 이미지의 결과 표시Ultralytics Conda Docker 이미지#
Conda Dockerfile은 conda-forge PyTorch 2.13, torchvision 0.28, CUDA 13.0을 사용합니다. conda-forge 릴리스는 표준 GPU 이미지에서 사용하는 PyTorch pip 릴리스보다 늦게 제공될 수 있습니다. latest-conda의 자동 게시가 비활성화되어 있으므로 최신 이미지를 로컬에서 빌드하세요:
git clone https://github.com/ultralytics/ultralytics
cd ultralytics
t=ultralytics-conda:local
sudo docker build -f docker/Dockerfile-conda -t $t .이미지를 실행합니다:
# Run the Ultralytics image in a container with GPU support
sudo docker run -it --ipc=host --device nvidia.com/gpu=all $t # all GPUs
sudo docker run -it --ipc=host --device nvidia.com/gpu=2 --device nvidia.com/gpu=3 $t # specify GPUsLinux에서 CDI 디바이스 요청을 사용하려면 Docker >= 28.2.0 및 NVIDIA Container Toolkit >= 1.18이 필요합니다. 기존 --gpus all 플래그를 사용하면 호스트 데몬을 다시 로드한 후 GPU에 액세스하지 못할 수 있으므로, 구형 Linux 호스트를 업그레이드하고 대신 --device을 사용하세요. 자세한 내용은 Docker 빠른 시작 가이드를 참조하세요.
Libmamba로 설치 속도 높이기#
libmamba은 Conda의 기존 solver를 대체하는 빠르고 크로스 플랫폼을 지원하며 종속성을 인식하는 solver입니다. Conda 23.10 이상에서는 이미 libmamba를 기본 solver로 사용하므로 대부분의 설치에서 별도의 설정 없이도 더 빠르게 작동합니다.
이전 버전의 Conda를 사용 중이라면 libmamba을 수동으로 활성화할 수 있습니다.
-
먼저
conda-libmamba-solver패키지를 설치합니다.conda install conda-libmamba-solver -
다음으로 Conda가
libmamba을 solver로 사용하도록 설정합니다.conda config --set solver libmamba
Conda 환경 설정과 Ultralytics 패키지 설치를 완료했으며, 이제 기능을 살펴볼 준비가 되었습니다. 고급 튜토리얼과 예제는 Ultralytics 문서를 참조하세요.
자주 묻는 질문#
한 번의 명령으로 conda-forge 채널의 Python과 Ultralytics를 사용해 환경을 생성하면 conda가 두 패키지를 함께 확인하고 해결합니다. 그런 다음 환경을 활성화합니다.
conda create --name ultralytics-env -c conda-forge python=3.11 ultralytics torchvision -y conda activate ultralytics-envConda는 pip보다 여러 장점을 제공하는 패키지 및 환경 관리 시스템입니다. 종속성을 효율적으로 관리하고 필요한 모든 라이브러리가 호환되도록 합니다. Conda의 격리된 환경은 패키지 간 충돌을 방지하며, 이는 데이터 과학 및 머신러닝 프로젝트에서 매우 중요합니다. 또한 Conda는 바이너리 패키지 배포를 지원해 설치 속도를 높입니다.
예. CUDA 지원 PyTorch 빌드가 함께 확인되도록
ultralytics과 conda-forgepytorch-gpu메타패키지를 같은 명령으로 환경에 설치합니다.conda create --name ultralytics-env -c conda-forge python=3.11 ultralytics torchvision pytorch-gpu -y conda activate ultralytics-env이 설정은 딥러닝 모델 학습 및 추론과 같은 고강도 작업에 필수적인 GPU 가속을 활성화합니다. 자세한 내용은 Ultralytics 설치 가이드를 참조하세요.
Conda Dockerfile은 CUDA가 활성화된 PyTorch가 포함된 격리형 conda-forge 환경을 제공합니다. 로컬 빌드 안내에 따라 빌드한 다음, 안내된 GPU 옵션을 사용해 실행하세요. 표준으로 게시된 GPU 이미지와 다른 대안은 Docker 가이드에 나와 있습니다.
Conda 23.10 이상에서는 이미 빠른
libmambasolver를 기본으로 사용합니다. 이전 버전의 Conda에서는 먼저conda-libmamba-solver패키지를 설치해 수동으로 활성화할 수 있습니다.conda install conda-libmamba-solver그런 다음 Conda가
libmamba을 solver로 사용하도록 설정합니다.conda config --set solver libmamba이 설정은 패키지 관리를 더 빠르고 효율적으로 수행할 수 있게 합니다.
댓글6
질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.
najwazkiyahh
Hi! I'm the new to using YOLO. I have python 3.12 on my laptop because my previous exam need it-the latest version of python. I want to install ultralytics YOLOv11, should I downgrade my python version from 3.12 into 3.11? Or I should downgrade my python version to the recommended requirement, 3.8? Thank you, hope you (anybody) can answer my confusion.
Glenn JocherUltralytics@najwazkiyahh you don't need to downgrade your system Python! 😊 Simply create a Conda environment with Python 3.11 using
conda create --name yolo_env python=3.11, then activate it and install Ultralytics. This keeps your existing Python 3.12 intact while giving you a compatible YOLO11 environment. For full steps, see the Conda Quickstart Guide for Ultralytics.We recommend this approach as it maintains version isolation while allowing you to work with both Python versions seamlessly. Welcome to the YOLO community! 🚀
Malvinlam
Hi is there a way to install the yolov8 dependencies using Anaconda prompt to the virtual environment other than pip install ultralytics? For example I already downloaded the ultralytics package from GitHub and opened it as project folder using PyCharm. Is there a way to only install the required libraries?
Glenn JocherUltralytics(수정됨)@Malvinlam hi there! 👋
Absolutely, you can install the required dependencies for Ultralytics using Conda without relying on
pip install ultralytics. Here's a step-by-step guide to help you set up your Conda environment and install the necessary libraries:-
Create a New Conda Environment: First, create a new Conda environment with Python 3.11 (or your preferred version):
conda create --name ultralytics-env python=3.11 -y -
Activate the Environment: Activate your newly created environment:
conda activate ultralytics-env -
Install Required Libraries: The repository no longer has a
requirements.txt; its dependencies are declared inpyproject.toml. From the root of your cloned repository, run:pip install -e .Alternatively, if you want to install specific packages manually, you can use:
conda install -c conda-forge numpy pandas matplotlib opencv scikit-learn conda install -c pytorch pytorch torchvision torchaudio -
Note on CUDA Environment: If you're working in a CUDA-enabled environment, it's a good practice to install
pytorchandpytorch-cudatogether to resolve any conflicts:conda install -c pytorch -c nvidia -c conda-forge pytorch torchvision torchaudio pytorch-cuda=11.8 -
Using Ultralytics: With the dependencies installed, you can now start using Ultralytics. For example, to perform inference with YOLO26:
from ultralytics import YOLO model = YOLO("yolo26n.pt") # initialize model results = model("path/to/image.jpg") # perform inference results[0].show() # display results for the first image
For more detailed instructions, you can refer to our Conda Quickstart Guide.
If you encounter any issues or have further questions, feel free to ask. Happy coding! 😊
-
nadinator
Does the python version have to be 3.8? Can it be a newer version? What would/wouldn't break if we used 3.11, for example (I'm thinking of the [ray]tuning feature)?
Glenn JocherUltralyticsHey there! 😊
You can definitely use Python versions newer than 3.8, including 3.11. However, it's important to note that while most features should work fine, there might be some compatibility issues with newer Python versions, especially with external libraries or specific features like [ray] tuning.
If you're keen on using Python 3.11, I'd recommend testing the key functionalities you plan to use in your project to ensure everything runs smoothly. For the [ray] tuning feature, you might want to check Ray's documentation or GitHub issues for any known compatibility concerns with Python 3.11.
Here's a quick example of how you might set up your environment with Python 3.11:
conda create --name ultralytics-env python=3.11 -y conda activate ultralytics-env conda install -c conda-forge ultralyticsAnd remember, if you encounter any issues, the Ultralytics community is here to help! 🚀