How to Install Ultralytics YOLO with Conda#
This guide walks through setting up a Conda environment for your Ultralytics projects. Conda is an open-source package and environment management system that offers an excellent alternative to pip for installing packages and dependencies. Its isolated environments make it particularly well-suited for data science and machine learning work. For more details, visit the Ultralytics Conda package on Anaconda and check out the Ultralytics feedstock repository for package updates on GitHub.
This guide covers how to create an environment, install Ultralytics, run inference, use the Conda Docker image, and speed up installs with libmamba.
Prerequisites#
You should have Anaconda or Miniconda installed on your system. If not, download and install it from Anaconda or Miniconda.
Setting up a Conda Environment#
First, create a new Conda environment. Open your terminal and run the following command:
conda create --name ultralytics-env python=3.11 -yActivate the new environment:
conda activate ultralytics-envInstalling Ultralytics#
You can install the Ultralytics package from the conda-forge channel. Execute the following command:
conda install -c conda-forge ultralyticsIf you're working in a CUDA-enabled environment, install ultralytics together with the conda-forge pytorch-gpu metapackage so the Conda package manager resolves a CUDA-enabled PyTorch build alongside it:
conda install -c conda-forge ultralytics pytorch-gpuUsing Ultralytics#
With Ultralytics installed, you can now start using its robust features for object detection, instance segmentation, and more. For example, to predict an image, you can run:
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 imageUltralytics Conda Docker Image#
The Conda Dockerfile uses conda-forge PyTorch 2.13, torchvision 0.28, and CUDA 13.0. Conda-forge releases can lag the PyTorch pip releases used by the standard GPU image. Automated publishing of latest-conda is disabled, so build the current image locally:
git clone https://github.com/ultralytics/ultralytics
cd ultralytics
t=ultralytics-conda:local
sudo docker build -f docker/Dockerfile-conda -t $t .Run the image:
# 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 GPUsOn Linux, CDI device requests require Docker >= 28.2.0 and NVIDIA Container Toolkit >= 1.18. The legacy --gpus all flag can lose GPU access after host daemon reloads, so upgrade older Linux hosts and use --device instead. See the Docker Quickstart Guide for details.
Speeding Up Installation with Libmamba#
libmamba is a fast, cross-platform, dependency-aware solver that replaces Conda's classic solver. Conda 23.10 and later already use libmamba as the default solver, so most installations are faster out of the box.
If you're on an older Conda version, you can enable libmamba manually:
-
First, install the
conda-libmamba-solverpackage:conda install conda-libmamba-solver -
Next, configure Conda to use
libmambaas the solver:conda config --set solver libmamba
You have successfully set up a Conda environment, installed the Ultralytics package, and are now ready to explore its features. For more advanced tutorials and examples, see the Ultralytics documentation.
FAQ#
Setting up a Conda environment for Ultralytics projects is straightforward and ensures smooth package management. First, create a new Conda environment using the following command:
conda create --name ultralytics-env python=3.11 -yThen, activate the new environment with:
conda activate ultralytics-envFinally, install Ultralytics from the conda-forge channel:
conda install -c conda-forge ultralyticsConda is a robust package and environment management system that offers several advantages over pip. It manages dependencies efficiently and ensures that all necessary libraries are compatible. Conda's isolated environments prevent conflicts between packages, which is crucial in data science and machine learning projects. Additionally, Conda supports binary package distribution, speeding up the installation process.
Yes, you can enhance performance by utilizing a CUDA-enabled environment. Install
ultralyticstogether with the conda-forgepytorch-gpumetapackage so a CUDA-enabled PyTorch build is resolved alongside it:conda install -c conda-forge ultralytics pytorch-gpuThis setup enables GPU acceleration, crucial for intensive tasks like deep learning model training and inference. For more information, visit the Ultralytics installation guide.
The Conda Dockerfile provides an isolated conda-forge environment with CUDA-enabled PyTorch. Follow the local build instructions, then run it with the GPU options shown there. The standard published GPU image and other alternatives are listed in the Docker guide.
Conda 23.10 and later already use the fast
libmambasolver by default. On older Conda versions, you can enable it manually by first installing theconda-libmamba-solverpackage:conda install conda-libmamba-solverThen configure Conda to use
libmambaas the solver:conda config --set solver libmambaThis setup provides faster and more efficient package management. For more tips on optimizing your environment, read about libmamba installation.