Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install pytorch with pip on Windows

Tags:

I'm trying to install Pytorch with Windows and I'm using the commands of the official site https://pytorch.org/get-started/locally/

pip3 install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html 

This is the command if I choose Windows, Cuda 10.0, and Python 3.7 But if I run this I get the error message:

ERROR: Could not find a version that satisfies the requirement torch==1.2.0 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch==1.2.0 

So why does this happen? My pip is version 19.2 and I am in a newly installed python 3.7 environment

like image 709
relot Avatar asked Aug 14 '19 16:08

relot


People also ask

Can you pip install PyTorch?

Package ManagerTo install the PyTorch binaries, you will need to use one of two supported package managers: Anaconda or pip.

Can we install PyTorch on Windows?

Currently, PyTorch on Windows only supports Python 3. x; Python 2. x is not supported. After the installation is complete, verify your Anaconda and Python versions.

Can I install PyTorch without CUDA?

You don't need to have cuda to install the cuda-enabled pytorch package but you need cuda to use it. We do not ship cuda with pytorch as it is a very big library.


2 Answers

I tried multiple solutions and it wasn't working on Windows 10 until I tried this:

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

If you want your GPU enabled then remove the "+CPU":

pip install torch==1.5.0 -f https://download.pytorch.org/whl/torch_stable.html 
like image 125
Raj Desai Avatar answered Oct 27 '22 11:10

Raj Desai


The most likely reason for Your issue is a 32-bit installation of python, while the torch libraries rely on having a 64-bit version. I had exactly the same issue.

Just start python from command line and observe

C:\Users\marci>python Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 

My installation now shows 64 bits. If Yours shows 32, then install 64-bit python. I used this link: Official python 64-bit Windows installer

like image 30
Marcin Gałczyński Avatar answered Oct 27 '22 09:10

Marcin Gałczyński