Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU version of torchvision requires non-CPU version of torch #5393

Closed
iamhatesz opened this issue Feb 9, 2022 · 9 comments
Closed

CPU version of torchvision requires non-CPU version of torch #5393

iamhatesz opened this issue Feb 9, 2022 · 9 comments

Comments

@iamhatesz
Copy link

馃悰 Describe the bug

Hi!

The +cpu wheels from here requires torch instead of torch+cpu. This works fine when installing with pip:

pip install torch==1.10.2+cpu torchvision==0.11.3+cpu torchaudio==0.10.2+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html

but fails with more advanced dependency managers like Poetry:

[tool.poetry.dependencies]
torch = {url = "https://download.pytorch.org/whl/cpu/torch-1.10.2%2Bcpu-cp39-cp39-linux_x86_64.whl"}
torchvision = {url = "https://download.pytorch.org/whl/cpu/torchvision-0.11.3%2Bcpu-cp39-cp39-linux_x86_64.whl"}
 Because torchvision (0.11.3+cpu) depends on torch (1.10.2)
   and my-project depends on torch (1.10.2+cpu), torchvision is forbidden.

And when you look into this wheel, you can indeed see:

Requires-Dist: torch (==1.10.2)

The proper value should be torch==1.10.2+cpu. I believe this matters, as torch installed from PyPI is ~900 MB, while torch+cpu installed from PyTorch index is only ~200 MB.

Versions

Collecting environment information...
PyTorch version: 1.10.2+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.3 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: Could not collect
CMake version: version 3.16.3
Libc version: glibc-2.31

Python version: 3.9.6 (default, Sep  8 2021, 10:04:08)  [GCC 9.3.0] (64-bit runtime)
Python platform: Linux-5.13.0-28-generic-x86_64-with-glibc2.31
Is CUDA available: False
CUDA runtime version: 11.0.221
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1080
Nvidia driver version: 470.103.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.22.2
[pip3] torch==1.10.2+cpu
[pip3] torchaudio==0.10.2+cpu
[pip3] torchvision==0.11.3+cpu
[conda] Could not collect
@Kavan72
Copy link

Kavan72 commented Feb 22, 2022

@iamhatesz Yep, you are right. I'm getting the same error, the only thing is how PyTorch team is managing release and packaging for vision.

@Kavan72
Copy link

Kavan72 commented Mar 23, 2022

@iamhatesz
Copy link
Author

Hey! Any update on this? Seems like a simple thing to fix, but produces a lot of issues with CPU-only wheels on CI pipelines.

@datumbox datumbox added this to Needs Triage in PyTorch Dev Infra Backlog via automation Jun 6, 2022
@seemethere seemethere self-assigned this Jun 6, 2022
@seemethere seemethere moved this from Needs Triage to Sprint TODO in PyTorch Dev Infra Backlog Jun 6, 2022
@seemethere
Copy link
Member

This appears to be what you're looking for: pytorch/pytorch#26340 (comment)

We introduced pep503 compliant indices to download.pytorch.org and they are now the recommended way to install pytorch. I believe that these can also be used with poetry as well.

@seemethere
Copy link
Member

Going to close this since pep503 compliant indices should resolve

Feel free to reopen if you feel like your issue has not been resolved

PyTorch Dev Infra Backlog automation moved this from Sprint TODO to Done Jun 7, 2022
@Kavan72
Copy link

Kavan72 commented Aug 13, 2022

hey @seemethere thanks for the update,

I guess the problem is still there while installing CPU wheels, check this

image

I've added the PyTorch site to the extra source, and getting the same error
here is my pyproject.toml

[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "poetry_test"}]

[tool.poetry.dependencies]
python = "^3.8"

[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
indexed = true
secondary = true

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

@chuanma
Copy link

chuanma commented Aug 21, 2022

@Kavan72 I also have the same issue. Before they find a proper way to fix this, I just add torchvision because torch will be added as a dependency. Note in the screenshot below that the CPU version of torch was correctly found where I also tried to add torchaudio. BTW, it worked with Poetry 1.2.0b3, but NOT with Poetry 1.1.14. Also I only tested it under linux.

poetry add torchvision --source pytorch-cpu

Image 2022-08-21 at 12 25 AM

@josearangos
Copy link

To try used

pip install --find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.10.0+cpu

@olsonperrensen
Copy link

If you need it in a req.txt file you should put -f https://download.pytorch.org/whl/torch_stable.html in a seperate line:

-f https://download.pytorch.org/whl/torch_stable.html
torch==2.0.1+cpu

(credit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants