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

dev: fix docker setup #460

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

dev: fix docker setup #460

wants to merge 2 commits into from

Conversation

rroohhh
Copy link
Member

@rroohhh rroohhh commented Feb 17, 2025

No description provided.

@rroohhh rroohhh requested review from phlmn, pajowu and anuejn February 17, 2025 18:10
@phlmn
Copy link
Member

phlmn commented Feb 18, 2025

noice!

It fails to install dependencies on my machine though. Maybe because of linux with aarch64?

#0 73.37 error: Distribution `torch==2.5.1+cpu @ registry+https://download.pytorch.org/whl/cpu` can't be installed because it doesn't have a source distribution or wheel for the current platform

@phlmn
Copy link
Member

phlmn commented Feb 18, 2025

Without using the pytorch-cpu index it seems to work just fine. Why are we using that anyway?

@rroohhh
Copy link
Member Author

rroohhh commented Feb 18, 2025

ugh, why does that break here now? It should be the same in docker and outside, no?

I think we are using it, because the non cpu variant pulls in cuda, etc, which are super large and quite unnecessary for the models we are running via torch, even if one would have a cuda compatible GPU.

Which setup did you use? The dev or the non dev setup? I think some problems with the dev setup are expected, because then you bind mount the venv's create by the host into the container, if those exist. I had to delete them manually to make it work, but I think this was always the case, even with the old docker setup.

@phlmn
Copy link
Member

phlmn commented Feb 18, 2025

Deleting the .venv folders or using the non-dev setup sadly does not fix the problem.

It should be the same in docker and outside, no?

In docker it should be linux-aarch64 (or linux-arm64?) outside it is darwin-aarch64, for which the version without +cpu is used. On that note: What is responsible for the distinctions? Don't see anything requiring them in the source files.

[[package]]
name = "torch"
version = "2.5.1"
source = { registry = "https://download.pytorch.org/whl/cpu" }
resolution-markers = [
    "python_full_version >= '3.12' and sys_platform == 'darwin'",
    "python_full_version < '3.12' and sys_platform == 'darwin'",
]
dependencies = [
    { name = "filelock", marker = "sys_platform == 'darwin'" },
    { name = "fsspec", marker = "sys_platform == 'darwin'" },
    { name = "jinja2", marker = "sys_platform == 'darwin'" },
    { name = "networkx", marker = "sys_platform == 'darwin'" },
    { name = "setuptools", marker = "python_full_version >= '3.12' and sys_platform == 'darwin'" },
    { name = "sympy", marker = "sys_platform == 'darwin'" },
    { name = "typing-extensions", marker = "sys_platform == 'darwin'" },
]
wheels = [
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1-cp311-none-macosx_11_0_arm64.whl", hash = "sha256:31f8c39660962f9ae4eeec995e3049b5492eb7360dd4f07377658ef4d728fa4c" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1-cp312-none-macosx_11_0_arm64.whl", hash = "sha256:8c712df61101964eb11910a846514011f0b6f5920c55dbf567bff8a34163d5b1" },
]

[[package]]
name = "torch"
version = "2.5.1+cpu"
source = { registry = "https://download.pytorch.org/whl/cpu" }
resolution-markers = [
    "python_full_version >= '3.12' and sys_platform != 'darwin'",
    "python_full_version < '3.12' and sys_platform != 'darwin'",
]
dependencies = [
    { name = "filelock", marker = "sys_platform != 'darwin'" },
    { name = "fsspec", marker = "sys_platform != 'darwin'" },
    { name = "jinja2", marker = "sys_platform != 'darwin'" },
    { name = "networkx", marker = "sys_platform != 'darwin'" },
    { name = "setuptools", marker = "python_full_version >= '3.12' and sys_platform != 'darwin'" },
    { name = "sympy", marker = "sys_platform != 'darwin'" },
    { name = "typing-extensions", marker = "sys_platform != 'darwin'" },
]
wheels = [
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-linux_x86_64.whl", hash = "sha256:07d7c9e069123d5af08b0cf0013d74f680b2d8be7d9e2cf561a52c90c55d9409" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp311-cp311-win_amd64.whl", hash = "sha256:81531d4d5ca74163dc9574b87396531e546a60cceb6253303c7db6a21e867fdf" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp312-cp312-linux_x86_64.whl", hash = "sha256:4856f9d6925121d13c2df07aa7580b767f449dfe71ae5acde9c27535d5da4840" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp312-cp312-win_amd64.whl", hash = "sha256:a6b720410350765d3d77c01a5ce098a6c45af446284e45e87a98b8a16e7d564d" },
    { url = "https://download.pytorch.org/whl/cpu/torch-2.5.1%2Bcpu-cp313-cp313-linux_x86_64.whl", hash = "sha256:5dbbdf83caa90d0bcaa50e4933ca424889133b35226db79000877d4ec5d9ea37" },
]
[[package]]
name = "speechbrain"
version = "0.5.16"
source = { registry = "https://pypi.org/simple" }
dependencies = [
    { name = "huggingface-hub" },
    { name = "hyperpyyaml" },
    { name = "joblib" },
    { name = "numpy" },
    { name = "packaging" },
    { name = "scipy" },
    { name = "sentencepiece" },
    { name = "torch", version = "2.5.1", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "sys_platform == 'darwin'" },
    { name = "torch", version = "2.5.1+cpu", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "sys_platform != 'darwin'" },
    { name = "torchaudio", version = "2.5.1", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "sys_platform == 'darwin'" },
    { name = "torchaudio", version = "2.5.1+cpu", source = { registry = "https://download.pytorch.org/whl/cpu" }, marker = "sys_platform != 'darwin'" },
    { name = "tqdm" },
]
sdist = { url = "https://files.pythonhosted.org/packages/73/9a/93661090bcf21f67401c034cbd7e18c7e9ca0d19e7fa9be465351c84e05b/speechbrain-0.5.16.tar.gz", hash = "sha256:cfbf6176da8879b541e1a2d1342d43806e82d0ef55604c2f38e21a5027a2eecb", size = 558217 }
wheels = [
    { url = "https://files.pythonhosted.org/packages/30/ff/9629de25786cf6ce38b7754b352a9904ce8c90b22a127d9d0d9c45ef5693/speechbrain-0.5.16-py3-none-any.whl", hash = "sha256:3b400b077d5b9c260c54ceadd4a1ae8e06d6f0b768e8e552bc0448b816f9050d", size = 630560 },
]

@phlmn
Copy link
Member

phlmn commented Feb 18, 2025

torch 2.6.0 seems to have a +cpu version for linux-aarch64 (https://download.pytorch.org/whl/torch/). But torchaudio would still be a problem (https://download.pytorch.org/whl/torchaudio/).

@rroohhh
Copy link
Member Author

rroohhh commented Feb 19, 2025

In docker it should be linux-aarch64 (or linux-arm64?) outside it is darwin-aarch64, for which the version without +cpu is used. On that note: What is responsible for the distinctions? Don't see anything requiring them in the source files.

right that makes sense. I just did not expect torch to just not have a aarch64 +cpu variant.

Well I guess the easiest option is to just also not use the torch+cpu variant on linux-aarch64, like we do on darwin...

@phlmn
Copy link
Member

phlmn commented Feb 20, 2025

Well I guess the easiest option is to just also not use the torch+cpu variant on linux-aarch64, like we do on darwin...

Yeah, but what does decide to use the non cpu-only variant on darwin? We are not explicitly specifying that

@phlmn
Copy link
Member

phlmn commented Feb 20, 2025

Seems like we can make uv care about linux aarch64 by adding:

[tool.uv]
environments = [
    "sys_platform == 'darwin' and platform_machine == 'x86_64'",
    "sys_platform == 'darwin' and platform_machine == 'arm64'",
    "sys_platform == 'linux' and platform_machine == 'x86_64'",
    "sys_platform == 'linux' and platform_machine == 'aarch64'",
]

Then it uses more specific resolution marker in uv.lock and adds the non cpu-only torch for linux aarch64

@phlmn
Copy link
Member

phlmn commented Feb 20, 2025

  error: assertion '(all (marker: ((pep508).evalMarkers environ' marker)) (attrValues (uvLock).supported-markers))' failed
       at /nix/store/q8bxd9h8rni05r9h3s5kdfd91vy30zqb-source/lib/overlays.nix:56:5:
           55|     # Assert that supported-environments is compatible with this environment
           56|     assert all (marker: pep508.evalMarkers environ' marker) (attrValues uvLock.supported-markers);
             |     ^
           57|     mapAttrs (

dafuq... shouldn't that be any instead of all?

1 similar comment
@phlmn
Copy link
Member

phlmn commented Feb 20, 2025

  error: assertion '(all (marker: ((pep508).evalMarkers environ' marker)) (attrValues (uvLock).supported-markers))' failed
       at /nix/store/q8bxd9h8rni05r9h3s5kdfd91vy30zqb-source/lib/overlays.nix:56:5:
           55|     # Assert that supported-environments is compatible with this environment
           56|     assert all (marker: pep508.evalMarkers environ' marker) (attrValues uvLock.supported-markers);
             |     ^
           57|     mapAttrs (

dafuq... shouldn't that be any instead of all?

@rroohhh
Copy link
Member Author

rroohhh commented Feb 20, 2025

Hmm good question, I dont really get why adding things to environments helps. The documentation says this can just restrict the considered platforms?. Maybe required-environments is what one actually wants to use?

@phlmn
Copy link
Member

phlmn commented Feb 20, 2025

That was what I tried first, but when I use required-environments it just complains that the key is not known

to bump uv, so `required-environments` works
@rroohhh
Copy link
Member Author

rroohhh commented Feb 20, 2025

So bumping uv to 0.6.1 at the least makes required-environments work, but it looks like uv2nix doesn't support the resulting lockfile yet :(

@rroohhh
Copy link
Member Author

rroohhh commented Feb 20, 2025

Lets see whats pyproject-nix/uv2nix#132 brings

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

Successfully merging this pull request may close these issues.

2 participants