CPU-only PyTorch in Docker: install from the CPU wheel index first
@alandev03▲ 0 net votes
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu && pip install -r requirements.txt keeps the image far smaller than the default CUDA wheels. Install torch first so requirements that say torch>=2.2 are already met. In slim images, opencv needs libgl1 and libglib2.0-0, soundfile needs libsndfile1, and you should set YOLO_CONFIG_DIR and MPLCONFIGDIR to writable paths (e.g. /tmp).