Environment setup instructions

Author: B10515007Created Feb 7, 2025Updated May 24, 2026

Motivation

Hi all, due to the unclear environment setup and the many questions in the issue, it took me two days to finally set it up successfully. I’d like to summarize my experience here to help more people.

Equipment

GTX 4090

nvcc
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

Installation

1. Install torch In my case, I install torch=2.0.0 with cuda 11.8 (according to nvcc -V result)

bash
pip install torch==2.0.0 torchvision==0.15.1 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118

2. Install mmcv Here is a mmcv official link: https://mmcv.readthedocs.io/en/latest/get_started/installation.html. And choose a proper version to device.(Fit above setting torch=2.0.0, cuda=11.8)

Image

IMPORTANT: When choosing mmcv version, do NOT choose >= 2.1.0.. Because Yolo world leverage mmyolo which version is 0.6.0. And the version shoud match mmcv>=2.0.0rc4, <2.1.0.(https://mmyolo.readthedocs.io/zh-cn/latest/get_started/dependencies.html)

3. Install requirement.txt Download this repo by

bash
git clone --recursive https://github.com/AILab-CVC/YOLO-World.git

And cd to ./requirements, install reuirement package by your case. For my case, I just want to inference so far, so I install demo_requirements.txt.

bash
pip install -r demo_requirements.txt

4. Install yolo-world This step is the most frustrating of all. When running pip install -e ., the system follows pyproject.toml to install packages. However, the package versions specified in pyproject.toml are incorrect. As a result, executing this command will cause pip to uninstall the existing packages (such as Torch, MMCV, etc.) and install the latest versions, which can mess up the proper package versions for your device.

So before running pip install -e ., we must install the proper package version manually.

bash
pip install transformers==4.33.0
pip install mmdet==3.3.0
pip install mmengine==0.10.6
pip install mmyolo==0.6.0

And then, edit dependencies in pyproject.toml in my case

"wheel",
"torch==2.0.0",
"torchvision==0.15.1",
"transformers==4.33.0",
"tokenizers",
"numpy",
"opencv-python",
"supervision==0.19.0",
"mmdet==3.3.0",
"mmengine==0.10.6",
"openmim",
"mmcv==2.0.0",
#'mmyolo @ git+https://github.com/onuralpszr/mmyolo.git',

Assign the packege version which installed to avoid pip re-install latest package.

After saving pyproject.toml we can run install script now.

bash
pip install -e .

5. Download weight and execute demo cammend

bash
python demo/image_demo.py configs/pretrain/yolo_world_v2_x_vlpan_bn_2e-3_100e_4x8gpus_obj365v1_goldg_train_lvis_minival.py weights/yolo_world_v2_x_obj365v1_goldg_cc3mlite_pretrain_1280ft-14996a36.pth demo/sample_images 'person,dog,cat' --topk 100 --threshold 0.005 --output-dir demo_outputs

Image

Trouble shooting

Problem 1

ImportError: Failed to import custom modules from {'imports': ['yolo_world'], 'allow_failed_imports': False}
...
...
You should set PYTHONPATH to make sys.path include the directory which contains your custom module

This means pip install -e . fail. The reason is the version of transformers is too old. Please reinstall a new one and re-install pip install -e . Solution issue: https://github.com/AILab-CVC/YOLO-World/issues/267 Relative issues: #218 #403

Problem 2

...
ModuleNotFoundError: No module named 'mmcv._ext'

When you install mmcv by pip, some people will see this error. Because some module of mmcv are not installed. Solution: Before execute pip to install mmcv, please export this two variables

bash
export MCV_WITH_OPS=1
export FORCE_CUDA=1

then install mmcv

bash
pip install mmcv==2.0.0 -f https://download.openmmlab.com/mmcv/dist/cu118/torch2.0/index.html

After install mmcv, we can check if ._ext module is installed successfully

python
import mmcv._ext

There are no error message, you install successfully.

Relative issues: #353 #231 #125 #198

Problem 3

AssertionError: MMCV==2.2.0 is used but incompatible. Please install mmcv>=2.0.0rc4, <2.2.0.

The error just like mmyolo message, according to https://mmyolo.readthedocs.io/zh-cn/latest/get_started/dependencies.html. The latest mmyolo=0.6.0 just support <mmcv2.1.0, so the highest mmcv version only 2.0.1 can be used. You should check your mmcv version by following, the output should under 2.1.0:

python
import mmcv
mmcv.__version
# print 2.0.1

https://mmyolo.readthedocs.io/zh-cn/latest/get_started/installation.html Image

Relative issues: #364 #279 #231

Problem 4

Building wheels for collected packages: tokenizers
  Building wheel for tokenizers (pyproject.toml) ... error
  error: subprocess-exited-with-error
  × Building wheel for tokenizers (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.linux-x86_64-cpython-310/tokenizers
      copying tokenizers/init.py -> build/lib.linux-x86_64-cpython-310/tokenizers
      running build_ext
      running build_rust
      error: can't find Rust compiler
      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.
      To update pip, run:
          pip install --upgrade pip
      and then retry package installation.
      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for tokenizers
Failed to build tokenizers
ERROR: Failed to build installable wheels for some pyproject.toml based projects (tokenizers)

Some problem when installing transformers. I found that when python=3.10, the above error message will show. Then I change python to 3.8, install transformers will be success.

Problem 5

Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]

      Cargo, the Rust package manager, is not installed or is not on PATH.
      This package requires Rust and Cargo to compile extensions. Install it through
      the system's package manager or via https://rustup.rs/

      Checking for Rust toolchain....
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

The error message refer to Cargo or Rust, but the real problem is about transformers. You should install transformers before pip install -e . , I trend not to rely on the cammend but manually install the transformers package. pip install transformers==4.33.0 in my case.

Thanks to the contributors for making YOLO-World an open-source repository. Also, thank you for reading this instruction — I hope it truly helps you!