33

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

1
  • I am new in python and was struggling with it. I found Anaconda very useful. Just installed it and then install any library that I want from Anaconda navigator. It is available for all OS. <br> docs.anaconda.com/anaconda/install/windows Commented Aug 15, 2019 at 10:25

13 Answers 13

28

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 
Sign up to request clarification or add additional context in comments.

6 Comments

Perfect this solved the install issue for me in Python 3.8
It does not work for me I get ERROR: Could not find a version that satisfies the requirement torch==1.5.0+cpu (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2) ERROR: No matching distribution found for torch==1.5.0+cpu
@QuintenCabo did you ever solve it? I also couldnt get this to work... thanks!
@yishairasowsky It seemed to be the version of python 32 bit instead of 64 bit. But trying to install it with Conda instead will probably also work better.
@QuintenCabo I have 64, and I have tried miniconda. still fails...
|
23

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

Comments

8

I had the same issue, and what I noticed is that I was using Python 3.8.1 and the latest PyTorch was for Python 3.7.

I uninstalled Python 3.8.1 and installed 3.7.6 and voila, it worked!

Not sure if this is your case, but it helped me.

2 Comments

torch 1.5.0 installs fine with python 3.8.3 in Ubuntu, but not in Windows 10. Even with python 3.7 torch 1.5.0 does not install on Win 10.
similar for me but I downgraded from 3.11 to 3.10 and works
7

So you have Cuda 10 installed? If you do, try this:

pip3 install https://download.pytorch.org/whl/cu100/torch-1.2.0-cp37-cp37m-win_amd64.whl 

followed by:

pip3 install torchvision 

To check if it was installed properly, type this into your command line:

python 

followed by:

from __future__ import print_function import torch x = torch.rand(5, 3) print(x) 

If you get this output:

tensor([[0.3380, 0.3845, 0.3217], [0.8337, 0.9050, 0.2650], [0.2979, 0.7141, 0.9069], [0.1449, 0.1132, 0.1375], [0.4675, 0.3947, 0.1426]]) 

PyTorch was installed correctly!

2 Comments

pytorch binaries (e.g. wheel, conda) come prepackaged with cuda so you shouldn't even need cuda installed on the system unless you build from source.
This answer is incorrect. The definitive way to determine if cuda is working is torch.cuda.is_available(). If it does not return True your code cannot use the GPU, but the above will look exactly the same.
4

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

Please use this, worked out for me.

Comments

1

Try installing via .whl file from Christoph Gohlke's repo at this link: https://www.lfd.uci.edu/~gohlke/pythonlibs/

Make sure you get the right one for your python version (cp37 at the bottom).

Navigate to the file or save it to your working directory, then use

pip3 install path-to-file.whl

Link to .whl file on page

2 Comments

This doesn't contain torch 1.2 and also not Cuda 10.0
Do you need that version of pytorch? (1.2) Might be easier to install an earlier version that has binaries built for windows. Unfortunately, this happens pretty frequently when using python via windows. Another option is using anaconda.
1

Go here https://pytorch.org/get-started/previous-versions/ and find the appropriate command for the version you want.

But first it is best to create an virtual environment with the right version of python

conda create -n you_env_name python=?.?.? 

Then activate the environment

conda activate your_env_name 

Comments

1

it's because your python version is 32bit while you're trying to download a 64bit version of Pytorch, navigate to pytorch_whl_page and choose an appreciate version of Pytorch or reinstall python from the official Python page to a 64bit version

Comments

0

try the following in your IDE command prompt then restart the IDE:

conda install pytorch -c pytorch 

Comments

0

You will find the correct code to run on the PyTorch website.

There, you can choose your OS, platform, pip, conda and other customisation. For example, the code to install the PyTorch package on Windows using pip and the CUDA 10.2 platform is (without the quotes:

"pip3 install torch==1.9.0+cu102 torchvision==0.10.0+cu102 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html"

Comments

0

Just downgrade your python version. I was using Python 3.10 then I uninstalled that and reinstalled python 3.7. It started working for me

Comments

0

As a fresh try, i ran into the same problem and it took me a long time but i solved at the end of efforts. After I saw this note "Currently, PyTorch on Windows only supports Python 3.8-3.11; Python 2.x is not supported." on https://pytorch.org/get-started/locally the lights flashed. I found 3.10.11 version and downloaded. In Cmd i typed "pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118" that command which stated on the website. After these steps my problem solved. I hope it can be useful to those who encounter the same problem.

Comments

-4

PyTorch is now torch.

import torch print(help("torch")) 

1 Comment

This answer does not address the question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.