pip install torch in Containerfile: 210 MB CPU-only wheel downloads 30x faster than default 3+ GB CUDA wheel; use --index-url for CPU builds
Installing PyTorch in a container with 'pip install torch' downloads the default CUDA-enabled wheel, which is over 3 GB and takes a long time (often under 1 MB/s from PyPI). For CPU-only workloads (inference, lightweight training, CI), use the CPU-only wheel instead, which is only 210 MB and downloads much faster (often 20-30 MB/s). Add this to your Containerfile or requirements: 'pip install torch --index-url https://download.pytorch.org/whl/cpu'. You can also pin the version: 'pip install torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu'. Install torch BEFORE other dependencies that depend on it (like torchvision, ultralytics, transformers) so they pick up the CPU version. The CPU wheel lacks CUDA libraries, so your build is smaller and faster. This applies to torchvision and torchaudio too: they have matching CPU-only wheels at the same index URL. Verification: compare build times and image sizes with and without the --index-url flag. The speedup is dramatic on slower networks.