Skip to content

Environment - Single TOML Support for GPU/CPU #49

@umar-anzar

Description

@umar-anzar

Unified CPU/GPU Dependency Setup

[project]
name = "test-toml"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12,<3.13"
dependencies = []





[project.optional-dependencies]
cpu = [
  "torch",
]
gpu = [
  "torch",
]



[tool.uv]
conflicts = [
    [
      { extra = "cpu" },
      { extra = "gpu" },
    ],
]



[tool.uv.sources]
torch = [
  { index = "torch-cpu", extra = "cpu" },
  { index = "torch-gpu", extra = "gpu"},
]



[[tool.uv.index]]
name = "torch-cpu"
url = "https://download.pytorch.org/whl/cpu"



[[tool.uv.index]]
name = "torch-gpu"
url = "https://download.pytorch.org/whl/cu126"

uv pip install -r .\pyproject.toml .[cpu]
uv pip install -r .\pyproject.toml .[gpu]
uv sync --extra cpu
uv sync --extra gpu

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
package-mode = false

[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"

[[tool.poetry.source]]
name = "pytorch-cuda"
url = "https://download.pytorch.org/whl/cu121"
priority = "explicit"


[tool.poetry.dependencies]
torch = [
    { markers = "extra == 'cpu' and extra != 'gpu'", source = "pytorch-cpu"},
    { markers = "extra == 'gpu' and extra != 'cpu'", source = "pytorch-cuda"},
]
torchvision = [
    { markers = "extra == 'cpu' and extra != 'gpu'", source = "pytorch-cpu"},
    { markers = "extra == 'gpu' and extra != 'cpu'", source = "pytorch-cuda"},
]


[project.optional-dependencies]
cpu = [
    "torch (>=2.7.1+cpu)",
    "torchvision (>=0.22.1+cpu)"
]
gpu = [
    "torch (==2.5.1+cu121)",
    "torchvision (>=0.20.1+cu121)",
]


[tool.poetry.group.dev.dependencies]
matplotlib = "^3.10.3"
ipykernel = "^6.29.5"
pyodbc = "^5.2.0"
augmentor = "^0.2.12"
scikit-learn = "^1.7.0"



[project]
name = "docparser-kyc"
version = "0.1.0"
description = "This is backend app for handling AI APIs of Docparser Project"
readme = "README.md"
requires-python = ">=3.11,<3.12"
dependencies = [

    "uvicorn[standard] (>=0.34.3,<0.35.0)",
    "fastapi[standard] (>=0.115.13,<0.116.0)",
    "gunicorn (>=23.0.0,<24.0.0)",
    "openai (>=1.91.0,<2.0.0)",
    "rapidfuzz (>=3.13.0,<4.0.0)",
    "opencv-python-headless (>=4.11.0.86,<5.0.0.0)",
    "pylibdmtx (>=0.1.10,<0.2.0)",
    "pyzbar (>=0.1.9,<0.2.0)",
    "qreader (>=3.16,<4.0)",
    "qrdet (>=2.5,<3.0)",
    "transformers (>=4.52.4,<5.0.0)",
    "timm (>=1.0.15,<2.0.0)",
    "easyocr (>=1.7.2,<2.0.0)",
    "pycryptodome (>=3.23.0,<4.0.0)",
    "aioodbc (>=0.5.0,<0.6.0)",
    "ultralytics (==8.3.159)",
    "urllib3 (>=2.5.0,<3.0.0)",
    "sqlalchemy (>=2.0.42,<3.0.0)"
]

poetry install
poetry install --extras "gpu"

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions