1

I would like to add lines for torch and torchvision on my requirements.txt file, to allow for easy clone, and I will be moving from computer to computer and to cloud in the near future.

I want an easy pip install -r requirements.txt and be done with it for my project.

> pip freeze > requirements.txt

gives something like

...
torch==1.5.0
torchvision==0.6.0
...

However, pip install -r requirements.txt (which is in fact pip install torch) doesn't work, and instead, as the official torch site, clearly says the command should be:

pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html

How do I make the requirements file reflect this?

My desktop is Windows 10.


Bonus question:

My cloud is Linux based.
How do I make the requirements file fit both desktop and cloud?

Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • Can you clarify what you mean by "doesn't work"? What is the error message you get? – David Z May 03 '20 at 21:46
  • @DavidZ Could not find a version that satisfies the requirement torch===1.5.0 (from -r requirements.txt (line 19)) (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) No matching distribution found for torch===1.5.0 (from -r requirements.txt (line 19)) – Gulzar May 03 '20 at 21:46
  • Oh, I meant edit it into the question. Information in comments may be lost after a while. – David Z May 03 '20 at 22:12

1 Answers1

5

You can use the same options in your requirements.txt file, e.g.

torch===1.5.0
torchvision===0.6.0
-f https://download.pytorch.org/whl/torch_stable.html

Then simply run pip install -r requirements.txt

michaeldel
  • 2,204
  • 1
  • 13
  • 19
  • nice. What about a version that is OS sensitive, or better, OS insensitive? – Gulzar May 03 '20 at 21:49
  • 1
    Also feasible on a _per line_ basis – sinoroc May 03 '20 at 21:50
  • @michaeldel Ok, Can you explain please why the commands in the official site are different? just for beauty for the linux users? – Gulzar May 03 '20 at 21:52
  • 1
    The specified packages may require external libraries (as binary or as source to compile) that might not get properly installed on Windows with `pip`, hence the `-f` requirement linking to compiled wheel files. See this answer for more info https://stackoverflow.com/a/29503549/1812262 – michaeldel May 03 '20 at 21:56
  • 1
    @sinoroc actually doesn't work inline with same error as I posted in my question. – Gulzar May 03 '20 at 22:07