You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Poetry发布Python包后,pip安装PyTorch自动选择CPU版而非CUDA版的问题求助

Poetry发布Python包后,pip安装PyTorch自动选择CPU版而非CUDA版的问题求助

I am new to poetry and I am working on a python package, I configured it with poetry and I built and published 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 though 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 worked fine when I did poetry install, but when I did poetry publish this happened

Poetry发布时的错误提示

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


备注:内容来源于stack exchange,提问作者Sanjith Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 18:19:52