uv icon indicating copy to clipboard operation
uv copied to clipboard

torch + transitive dependency leads to unnecessary packages

Open senysenyseny16 opened this issue 4 months ago • 4 comments

Hello! I found that uv installs unnecessary (transitive) dependencies:

Reproducing:

uv venv -p python3.10
source .venv/bin/activate
uv pip install torch==2.1.2+cpu --index-url https://download.pytorch.org/whl/cpu
Resolved 9 packages in 3.14s
Installed 9 packages in 255ms
 + filelock==3.13.1
 + fsspec==2024.2.0
 + jinja2==3.1.3
 + markupsafe==2.1.5
 + mpmath==1.3.0
 + networkx==3.2.1
 + sympy==1.12
 + torch==2.1.2+cpu
 + typing-extensions==4.9.0
uv pip install opencv-python torch==2.1.2  # imagine torch==2.1.2 is opencv-python package dependency
Resolved 24 packages in 1.49s
Prepared 2 packages in 37.71s
Installed 15 packages in 37ms
 + numpy==2.1.2
 + nvidia-cublas-cu12==12.1.3.1
 + nvidia-cuda-cupti-cu12==12.1.105
 + nvidia-cuda-nvrtc-cu12==12.1.105
 + nvidia-cuda-runtime-cu12==12.1.105
 + nvidia-cudnn-cu12==8.9.2.26
 + nvidia-cufft-cu12==11.0.2.54
 + nvidia-curand-cu12==10.3.2.106
 + nvidia-cusolver-cu12==11.4.5.107
 + nvidia-cusparse-cu12==12.1.0.106
 + nvidia-nccl-cu12==2.18.1
 + nvidia-nvjitlink-cu12==12.6.77
 + nvidia-nvtx-cu12==12.1.105
 + opencv-python==4.10.0.84
 + triton==2.1.0

But in this case nvidia/triton deps are not needed, they are from PyPI CUDA torch:

DEBUG Searching for a compatible version of torch (==2.1.2)
DEBUG Selecting: torch==2.1.2 [compatible] (torch-2.1.2-cp310-cp310-manylinux1_x86_64.whl)
DEBUG Adding transitive dependency for torch==2.1.2: filelock*
DEBUG Adding transitive dependency for torch==2.1.2: typing-extensions*
DEBUG Adding transitive dependency for torch==2.1.2: sympy*
DEBUG Adding transitive dependency for torch==2.1.2: networkx*
DEBUG Adding transitive dependency for torch==2.1.2: jinja2*
DEBUG Adding transitive dependency for torch==2.1.2: fsspec*
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cuda-nvrtc-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.105
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cuda-runtime-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.105
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cuda-cupti-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.105
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cudnn-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==8.9.2.26
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cublas-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.3.1
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cufft-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==11.0.2.54
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-curand-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==10.3.2.106
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cusolver-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==11.4.5.107
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-cusparse-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.0.106
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-nccl-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==2.18.1
DEBUG Adding transitive dependency for torch==2.1.2: nvidia-nvtx-cu12{platform_machine == 'x86_64' and platform_system == 'Linux'}==12.1.105
DEBUG Adding transitive dependency for torch==2.1.2: triton{platform_machine == 'x86_64' and platform_system == 'Linux'}==2.1.0

linux x86_64, uv 0.4.11

Is there work around? The situation is even worse when installing Torch with a specific version of CUDA (https://download.pytorch.org/whl/cu118 for example)

senysenyseny16 avatar Oct 08 '24 10:10 senysenyseny16