1

I am new to poetry and I am working on a python package, I configured it with poetry and I built and pusblished it. Here is the pyproject.toml file


[tool.poetry.dependencies]
python = "^3.12"
pytest = "^8.3.4"
opencv-python = "^4.10.0.84"
cython = "^3.0.11"
jupyterlab = "^4.3.3"
torch = {version = "2.4.1", source = "pytorch"}
torchvision = {version = "0.19.1", source = "pytorch"}
facenet-pytorch = "2.5.3"


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

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Before publishing I just wanted to test whether it worked... so I did poetry install and this worked totally fine, it installed the cuda version, but when I published it and did pip install it installed the CPU version even thought my system has a GPU... so after that i tried a different way

[tool.poetry.dependencies]
python = "^3.12"
pytest = "^8.3.4"
torch = { version = "^2.2.1", extras = ["cuda"], source = "pytorch" }
torchvision = { version = "^0.17.0", extras = ["cuda"],source = "pytorch" }
facenet-pytorch = "2.5.3"
opencv-python = "^4.10.0.84"
cython = "^3.0.11"
jupyterlab = "^4.3.3"

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

again this also worked fine with poetry install, but when I did pip install I got this on the terminal log

WARNING: torch 2.5.1 does not provide the extra 'cuda'
INFO: pip is looking at multiple versions of torch[cuda] to determine which version is compatible with other requirements. This could take a while.
Collecting torch[cuda]>=1.12.1 (from identity_clustering==0.0.5)
  Downloading torch-2.5.0-cp312-cp312-win_amd64.whl.metadata (28 kB)
WARNING: torch 2.5.0 does not provide the extra 'cuda'
  Using cached torch-2.4.1-cp312-cp312-win_amd64.whl.metadata (27 kB)
WARNING: torch 2.4.1 does not provide the extra 'cuda'
  Downloading torch-2.4.0-cp312-cp312-win_amd64.whl.metadata (27 kB)
WARNING: torch 2.4.0 does not provide the extra 'cuda'
  Downloading torch-2.3.1-cp312-cp312-win_amd64.whl.metadata (26 kB)
WARNING: torch 2.3.1 does not provide the extra 'cuda'
  Downloading torch-2.3.0-cp312-cp312-win_amd64.whl.metadata (26 kB)
WARNING: torch 2.3.0 does not provide the extra 'cuda'
WARNING: torch 2.2.2 does not provide the extra 'cuda'
WARNING: torchvision 0.17.2 does not provide the extra 'cuda'

and at last it simply installed the cpu version...

finally I was looking up for other options and I saw few scripts where people explicitly mentioned cuda so I tried that

[tool.poetry.dependencies]
python = "^3.12"
pytest = "^8.3.4"
opencv-python = "^4.10.0.84"
cython = "^3.0.11"
jupyterlab = "^4.3.3"
torch = {version = "^2.4.1+cu118", source = "pytorch"}
torchvision = {version = "^0.19.1+cu118", source = "pytorch"}
facenet-pytorch = "2.5.3"


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

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

again it woked fine when I did poetry install, but when I did poetry publish this happened

image

I am working on a windows system and using cuda 11.8 toolkit... any idea how should I solve this?

5
  • pip is not respecting the version. you could probably have a [dependecies] section that pip could understand. Or, export requirements and use it with pip poetry export -f requirements.txt Commented Dec 19, 2024 at 14:13
  • how can I add a [dependencies] isn't it the same as [tool.poetry.dependecies]? @LMC Commented Dec 19, 2024 at 15:27
  • the poetry one is specific for poetry, [dependencies] is for setuptools, i.e. pip Commented Dec 19, 2024 at 15:29
  • Ok got it... so here the issue is actually with pip which is not able to properly parse the dependecy versions and install them as poetry does...? so its better to go with setuptools or manually install torch cuda version? @LMC Commented Dec 19, 2024 at 16:24
  • You could try pip3.12 but passing version pip3.12 install torch==2.4.1 Commented Dec 19, 2024 at 16:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.