Unable to install the correct version


I created a virtual environment and wanted to install the current latest stable version (1.7) with the following command:

pip install torch==1.7.0+cu110 torchvision==0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

When I check the version, it seems that 1.4.0 is installed:

import torch
>>> print(torch.__version__)

Does anyone know why the 1.7.0 version is not installed?

This is the output from the installation procedure:

Installing collected packages: torch, torchvision
  Found existing installation: torch 1.7.0+cu101
    Uninstalling torch-1.7.0+cu101:
      Successfully uninstalled torch-1.7.0+cu101
  Found existing installation: torchvision 0.8.1+cu101
    Uninstalling torchvision-0.8.1+cu101:
      Successfully uninstalled torchvision-0.8.1+cu101
Successfully installed torch-1.7.0+cu110 torchvision-0.8.1+cu110

If I try to install it in conda environment (using conda install), the versions match.

I guess you might have multiple PyTorch installations in your current environment, so before installing the latest 1.7.0 version you should uninstall the older ones.