-
Notifications
You must be signed in to change notification settings - Fork 228
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
feat: Add pytorch example #2123
Conversation
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64"] | ||
system-requirements = { cuda = "12.1" } | ||
|
||
[feature.pytorch-from-pytorch] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples from pixi mention the use of pytorch from the pytorch-channel in conjunction with conda-forge. However, please note this does not seem supported and can create unstable environments (ref1, ref2). If you notice well, the pytorch documentation uses defaults
. I copied these from the pixi user guide sometime ago and found issues extending the proposed environments with other conda-forge packages (check references). I wonder if the manual should mention unsupported use-cases like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for you input! I wasn't aware. I'll take another look. I'm not going to use the defaults channel in one of our example so I might have to wait for the release of the full pytorch work on conda-forge.
Installing pytorch is a very common use case, so it's good to have one or more examples on pixi! The current one is demonstrating three different ways to install pytorch which very insightful, but I feel an additional example that better reflects a "real world" situation would help the downstream users as well. I am saying that because I recently had to set up a repo with pytorch, and it took me some time to get the feature/env logic right. I ended up with two approaches: Two envs
[project]
name = "xxx"
version = "0.1.0"
description = "Add a short description here"
authors = ["xxx <[email protected]>"]
channels = ["https://fast.prefix.dev/conda-forge"]
platforms = ["osx-arm64", "linux-64"] # let's ignore win-64 for now
[tasks]
[dependencies]
python = ">=3.11,<4"
transformers = ">=4.44,<5"
tokenizers = ">=0.19.1,<0.20"
jupyterlab = ">=4.2.5,<5"
pandas = ">=2.2.3,<3"
accelerate = ">=0.34.2,<0.35"
safetensors = ">=0.4.5,<0.5"
pytorch = ">=2.4,<3"
[environments]
cuda = { features = ["cuda"] }
default = { features = ["cpu"] }
[feature.cuda]
platforms = ["linux-64"]
system-requirements = { cuda = "12" }
dependencies = { pytorch = { build = "*cuda*" } }
[feature.cpu.dependencies]
pytorch = { version = "*", build = "*cpu*" } Three envs but one empty
[project]
name = "xxx"
version = "0.1.0"
description = "Add a short description here"
authors = ["xxx <[email protected]>"]
channels = ["https://fast.prefix.dev/conda-forge"]
platforms = ["osx-arm64", "linux-64"] # let's ignore win-64 for now
[tasks]
[feature.common.dependencies]
python = ">=3.11,<4"
transformers = ">=4.44,<5"
tokenizers = ">=0.19.1,<0.20"
jupyterlab = ">=4.2.5,<5"
pandas = ">=2.2.3,<3"
accelerate = ">=0.34.2,<0.35"
safetensors = ">=0.4.5,<0.5"
pytorch = ">=2.4,<3"
[environments]
cuda = { features = ["cuda", "common"] }
cpu = { features = ["cpu", "common"] }
[feature.cuda]
platforms = ["linux-64"]
system-requirements = { cuda = "12" }
dependencies = { pytorch = { build = "*cuda*" } }
[feature.cpu.dependencies]
pytorch = { version = "*", build = "*cpu*" } You could also have three envs with Any feedback or ideas to improve the logics are welcome. |
Feedback: I tried the first example locally, but this strategy does not seem to work if one uses a |
I debugged the problem a bit more and I can confirm that the reason why this configuration does not work regards the addition of a |
Here is a version of your example, and with [project]
name = "xxx"
version = "0.1.0"
description = "Add a short description here"
authors = ["xxx <[email protected]>"]
channels = ["https://fast.prefix.dev/conda-forge"]
platforms = ["osx-arm64", "linux-64"] # let's ignore win-64 for now
[dependencies]
python = ">=3.11,<4"
pytorch = ">=2.4,<3"
[pypi-dependencies]
tabulate = "*"
[environments]
cuda = { features = ["cuda"] }
[feature.cuda]
system-requirements = { cuda = "12" } That said, I agree this issue must be resolved so we can explicitly mark certain features only are sensical in the given platforms. |
Thanks a lot for helping! The pypi-dependencies issue is known. I was indeed planning to create a more real-world example but since there are a lot of routes to take I started with only the basics so users could learn from those. |
Maybe two examples would actually be best given how tricky the torch situation can be sometime :-) The one in this PR discussing the historical differences between the different channels and another one, more rooted in real-world with separate envs cuda/cpu. |
@ruben-arts: IMO this problem has 2 parts:
(Example: One of the examples in the documentation is extremely convoluted and is not supported by pytorch or conda-forge. I think it would be better to remove it.)
After one solves #1051, we can go back to the examples and remove the warnings. Example from @hadim simplified to the bare minimum (this resolves for me correctly using pixi version 0.30): [project]
name = "pytorch-from-conda-forge"
channels = ["conda-forge"]
platforms = ["osx-arm64", "linux-64"]
[dependencies]
python = "3.*"
pytorch = "*"
# WARNING: Cannot add PyPI dependencies or use pyproject.toml as manifest while
# https://github.com/prefix-dev/pixi/issues/1051 is not fixed
# [pypi-dependencies]
# tabulate = "*"
[feature.cuda]
platforms = ["linux-64"]
system-requirements = { cuda = "12" }
[environments]
cuda = { features = ["cuda"] } Similar example but with [project]
name = "pytorch-from-pytorch"
channels = ["pytorch", "anaconda"]
platforms = ["osx-arm64", "linux-64"]
[dependencies]
python = "3.*"
pytorch = "*"
# WARNING: Cannot add PyPI dependencies or use pyproject.toml as manifest while
# https://github.com/prefix-dev/pixi/issues/1051 is not fixed
# [pypi-dependencies]
# tabulate = "*"
[feature.cuda]
channels = ["pytorch", "nvidia", "anaconda"]
platforms = ["linux-64"]
system-requirements = { cuda = "12.4" }
dependencies = { pytorch-cuda = { version = "12.4" } }
[environments]
cuda = { features = ["cuda"] } |
Might be nice to have an example using |
Both Please note that the |
No description provided.