Skip to content

Instantly share code, notes, and snippets.

@sglbl
Last active January 8, 2025 15:17
Show Gist options
  • Select an option

  • Save sglbl/713c0d34ed39a14c29291f8db6c7f85c to your computer and use it in GitHub Desktop.

Select an option

Save sglbl/713c0d34ed39a14c29291f8db6c7f85c to your computer and use it in GitHub Desktop.
Uv pyproject.toml file for Torch cpu/gpu selection
# This template toml file works with pytorch cpu and gpu versions using 'uv sync --extra cpu' and 'uv sync --extra gpu' commands
[project]
name = "digit-classification"
version = "0.1.0"
description = "Digit classification project"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"gradio==5.6.0",
"matplotlib==3.9.2",
"numpy==2.1.3",
"opencv-python>=4.10.0.84",
"transformers>=4.46.3",
]
[dependency-groups]
dev = [
"jupyter>=1.1.1",
"pytest>=8.3.3",
]
[project.optional-dependencies]
cpu = [
"torch>=2.5.1",
]
gpu = [
"torch>=2.5.1",
]
[tool.uv]
conflicts = [
[
{ extra = "cpu" },
{ extra = "gpu" },
],
]
[tool.uv.sources]
torch = [
{ index = "pytorch-cpu", extra = "cpu", marker = "platform_system != 'Darwin'" },
{ index = "pytorch-gpu", extra = "gpu" },
]
[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true
[[tool.uv.index]]
name = "pytorch-gpu"
url = "https://download.pytorch.org/whl/cu124"
explicit = true
[tool.pytest.ini_options]
pythonpath = "."
filterwarnings = ["ignore::DeprecationWarning", "ignore::FutureWarning"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment