Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should I handle cross compatibility with the torch dependency? #10399

Open
MattTheCuber opened this issue Jan 8, 2025 · 2 comments
Open

Comments

@MattTheCuber
Copy link

MattTheCuber commented Jan 8, 2025

Note, this seems to be an question with all Python dependency tools. However, I wasn't able to find any documentation on the problem online.

I use the uv pip method with requirements.txt. When I add torch to my pyproject.toml -> project.dependencies, then run uv pip compile, it creates a requirements.txt with a bunch of Linux-specific dependencies for nvidia packages such as nvidia-cublas-cu12 and nvidia-nccl-cu12. This works and makes sense for Linux. However, if you are building a cross-platform compatible tool, this does not work on Windows. When running uv pip install torch on Windows, those nvidia dependencies are not installed. This makes uv pip sync fail on Windows.

The only solutions I came up with are to remove the dependencies from the requirements file manually or use --no-emit-package.

@MattTheCuber
Copy link
Author

MattTheCuber commented Jan 8, 2025

This is what I mean for the --no-emit-package.

[tool.uv.pip]
no-emit-package = [
    "nvidia-cublas-cu12",
    "nvidia-cuda-cupti-cu12",
    "nvidia-cuda-nvrtc-cu12",
    "nvidia-cuda-runtime-cu12",
    "nvidia-cudnn-cu12",
    "nvidia-cufft-cu12",
    "nvidia-curand-cu12",
    "nvidia-cusolver-cu12",
    "nvidia-cusparse-cu12",
    "nvidia-nccl-cu12",
    "nvidia-nvjitlink-cu12",
    "nvidia-nvtx-cu12",
]

It works, but I feel like their is a better way of handling this that I don't know about.

EDIT:
This does not work when re-running pip sync on Linux because those packages are required.

@MattTheCuber
Copy link
Author

MattTheCuber commented Jan 8, 2025

I think this may work?

[project]
...
dependencies = [
    "nvidia-cublas-cu12; sys_platform=='linux'",
    "nvidia-cuda-cupti-cu12; sys_platform=='linux'",
    "nvidia-cuda-nvrtc-cu12; sys_platform=='linux'",
    "nvidia-cuda-runtime-cu12; sys_platform=='linux'",
    "nvidia-cudnn-cu12; sys_platform=='linux'",
    "nvidia-cufft-cu12; sys_platform=='linux'",
    "nvidia-curand-cu12; sys_platform=='linux'",
    "nvidia-cusolver-cu12; sys_platform=='linux'",
    "nvidia-cusparse-cu12; sys_platform=='linux'",
    "nvidia-nccl-cu12; sys_platform=='linux'",
    "nvidia-nvjitlink-cu12; sys_platform=='linux'",
    "nvidia-nvtx-cu12; sys_platform=='linux'",
]

Maybe as a constraint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant