question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pytorch and torchvision CPU version install fails

See original GitHub issue

Hello, I wanted to install CPU version of torch 1.6.0 and torchvision 0.7.0 it’s similar issue like #4422 and #4171 but in my case, pipenv unable to solve requirements even they are written in pipenv file

Issue description

Requirements check fails with expectation of pinned package version

Expected result

Torch and torchvision are installed

Actual result

Current constraints:
  torch==1.6.0+cpu from https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch (from -r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 3))
  torchvision==0.7.0+cpu from https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision (from -r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 2))

Finding the best candidates:
  found candidate https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch (constraint was ==1.6.0+cpu)
  found candidate https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision (constraint was ==0.7.0+cpu)

Finding secondary dependencies:
  https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision requires numpy, pillow>=4.1.1, torch==1.6.0
  https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch requires future, numpy

New dependencies found in this round:
  adding ['future', '', '[]']
  adding ['numpy', '', '[]']
  adding ['pillow', '>=4.1.1', '[]']
  adding ['torch', '==1.6.0', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  future (from torch==1.6.0+cpu->-r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 3))
  numpy (from torch==1.6.0+cpu->-r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 3))
  pillow>=4.1.1 (from torchvision==0.7.0+cpu->-r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 2))
  torch==1.6.0,==1.6.0+cpu from https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch (from -r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 3))
  torchvision==0.7.0+cpu from https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision (from -r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 2))

Finding the best candidates:
  found candidate future==0.18.2 (constraint was <any>)
  found candidate numpy==1.19.2 (constraint was <any>)
  found candidate pillow==8.0.1 (constraint was >=4.1.1)
  found candidate https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch (constraint was ==1.6.0,==1.6.0+cpu)
  found candidate https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision (constraint was ==0.7.0+cpu)

Finding secondary dependencies:
  numpy==1.19.2             requires -
  pillow==8.0.1             requires -
  https://download.pytorch.org/whl/cpu/torchvision-0.7.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torchvision requires numpy, pillow>=4.1.1, torch==1.6.0
  future==0.18.2            requires -
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 807, in <module>
    main()
  File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 803, in main
    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
  File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 785, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 753, in resolve_packages
    requirements_dir=requirements_dir,
  File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 736, in resolve
    req_dir=requirements_dir
  File "/usr/lib/python3.6/site-packages/pipenv/utils.py", line 1386, in resolve_deps
    req_dir=req_dir,
  File "/usr/lib/python3.6/site-packages/pipenv/utils.py", line 1093, in actually_resolve_deps
    resolver.resolve()
  File "/usr/lib/python3.6/site-packages/pipenv/utils.py", line 808, in resolve
    results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
  File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 180, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 268, in _resolve_one_round
    their_constraints.extend(self._iter_dependencies(best_match))
  File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 369, in _iter_dependencies
    "Expected pinned or editable requirement, got {}".format(ireq)
TypeError: Expected pinned or editable requirement, got torch==1.6.0,==1.6.0+cpu from https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl#egg=torch (from -r /tmp/pipenv9nl1jcq7requirements/pipenv-cwkg_khz-constraints.txt (line 3))

Steps to replicate

command pipenv lock -v

Pipfile contents

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
torch = {file = "https://download.pytorch.org/whl/cpu/torch-1.6.0%252Bcpu-cp37-cp37m-linux_x86_64.whl"}
torchvision = {file = "https://download.pytorch.org/whl/cpu/torchvision-0.7.0%252Bcpu-cp37-cp37m-linux_x86_64.whl"}

Pipenv version: '2020.8.13' Python version 3.6.10

I have tried also with latest python 3.8 version - but it does not change anything. Specifying version field in package settings also does not help

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
MoRoBe-Workcommented, Sep 13, 2021

I use the line torch = {index = "pytorch", version = "==1.9.0+cu111"} under packages and torch.__version__ shows 1.9.0+cu111

Does this work for you as well?

1reaction
matsutakkcommented, Sep 13, 2021

It works😀 I got a step closer to graduation thanks to you.

Thank you so much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible error when installing pytorch-cpu via conda
Hi, when I issue the command, as listed on the website: conda install pytorch-cpu torchvision -c pytorch I would expect the package pytorch...
Read more >
Error Installing Torch To Windows 11 Pro - PyTorch Forums
I checked using “python -V” that the system thinks it is is using that version. When I now run the command. pip3 install...
Read more >
PyTorch installation problems with stable, windows, pip ...
ERROR : no matching distribution found for torch. I have tried older versions such as: pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f ...
Read more >
Issue with pip installation of PyTorch
pip3 install torch torchvision torchaudio --extra-index-url ... __version__ '1.12.0+cpu' >>> torch.cuda.get_arch_list() []. Then I installed ...
Read more >
Install pytorch 1.9.0 with unexpected problem
conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 ... after installment finished, it seems cpu version is installed,not GPU.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found