PyTorch keep installing wrong version

username: xucaojin
cooked: <p>I am having a hard time installing the correct PyTorch version 1.13.<br>
I am using Python 3.9.13,<br>
Cuda compilation tools, release 11.7, V11.7.64,<br>
and pip 22.3.1</p>
<p>following the command from pytorch website:</p>
<pre><code class="lang-auto">pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
</code></pre>
<p>It keeps installing torch 1.11.0 with no CUDA support.</p>
<pre><code class="lang-auto">&gt;&gt;&gt; import torch
&gt;&gt;&gt;
&gt;&gt;&gt; torch.cuda.is_available()
False
&gt;&gt;&gt; torch.__version__
'1.11.0+cpu'
&gt;&gt;&gt; torch.cuda.init()
AssertionError: Torch not compiled with CUDA enabled
</code></pre>
<p>How do I fix this?</p>

username: ptrblck
cooked: <p>The command works for me:</p>
<pre><code class="lang-auto">pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch
  Downloading https://download.pytorch.org/whl/cu117/torch-1.13.1%2Bcu117-cp39-cp39-linux_x86_64.whl (1801.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 GB 55.0 MB/s eta 0:00:00
Collecting torchvision
  Downloading https://download.pytorch.org/whl/cu117/torchvision-0.14.1%2Bcu117-cp39-cp39-linux_x86_64.whl (24.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 24.3/24.3 MB 57.3 MB/s eta 0:00:00
Collecting torchaudio
  Downloading https://download.pytorch.org/whl/cu117/torchaudio-0.13.1%2Bcu117-cp39-cp39-linux_x86_64.whl (4.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.2/4.2 MB 56.0 MB/s eta 0:00:00
...
Successfully installed certifi-2022.12.7 charset-normalizer-2.1.1 idna-3.4 numpy-1.24.1 pillow-9.4.0 requests-2.28.1 torch-1.13.1+cu117 torchaudio-0.13.1+cu117 torchvision-0.14.1+cu117 typing-extensions-4.4.0 urllib3-1.26.13
</code></pre>
<pre><code class="lang-python">Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03) 
[GCC 10.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.13.1+cu117'
&gt;&gt;&gt; import torchvision
&gt;&gt;&gt; torchvision.__version__
'0.14.1+cu117'
&gt;&gt;&gt; import torchaudio
&gt;&gt;&gt; torchaudio.__version__
'0.13.1+cu117'
</code></pre>
<p>However, I don’t understand why you don’t use the supported command from <a href="https://pytorch.org/get-started/locally/">the install instructions</a>:</p>
<pre><code class="lang-auto">pip3 install torch torchvision torchaudio
</code></pre>
<p>instead but want to specify the <code>extra-index-url</code>.</p>

username: xucaojin
cooked: <p>the command is from <a href="https://pytorch.org/get-started/locally/" class="inline-onebox" rel="noopener nofollow ugc">Start Locally | PyTorch</a>.<br>
I tried to uninstall and install using the command you give</p>
<pre><code class="lang-auto">C:\...&gt;pip3 install torch torchvision torchaudio
Collecting torch
  Downloading torch-1.13.1-cp39-cp39-win_amd64.whl (162.5 MB)
     ---------------------------------------- 162.5/162.5 MB 3.1 MB/s eta 0:00:00
Requirement already satisfied: torchvision in c:\...\python\python39\lib\site-packages (0.12.0)
Requirement already satisfied: torchaudio in c:\...\python\python39\lib\site-packages (0.11.0)
Requirement already satisfied: typing-extensions in c:\users\...\python\python39\lib\site-packages (from torch) (4.4.0)
  Using cached torch-1.11.0-cp39-cp39-win_amd64.whl (157.9 MB)
Requirement already satisfied: numpy in c:\users\...\python\python39\lib\site-packages (from torchvision) (1.24.1)
Requirement already satisfied: pillow!=8.3.*,&gt;=5.3.0 in c:\users\...\python\python39\lib\site-packages (from torchvision) (9.4.0)
Requirement already satisfied: requests in c:\users\...\python\python39\lib\site-packages (from torchvision) (2.28.1)
Requirement already satisfied: certifi&gt;=2017.4.17 in c:\users\...\python\python39\lib\site-packages (from requests-&gt;torchvision) (2022.12.7)
Requirement already satisfied: charset-normalizer&lt;3,&gt;=2 in c:\users\...\python\python39\lib\site-packages (from requests-&gt;torchvision) (2.1.1)
Requirement already satisfied: urllib3&lt;1.27,&gt;=1.21.1 in c:\users\...\python\python39\lib\site-packages (from requests-&gt;torchvision) (1.26.13)
Requirement already satisfied: idna&lt;4,&gt;=2.5 in c:\users\...\python\python39\lib\site-packages (from requests-&gt;torchvision) (3.4)
Installing collected packages: torch
Successfully installed torch-1.11.0
</code></pre>
<p>it downloaded the right version then installed 1.11.0 instead</p>

username: ptrblck
cooked: <p>Sorry, I didn’t realize you are using Windows in which case your command seems to be right.</p>
<pre><code class="lang-auto">Using cached torch-1.11.0-cp39-cp39-win_amd64.whl (157.9 MB)
</code></pre>
<p>this indicates that a cached version is used for whatever reason. Uninstall all PyTorch binaries from the current environment and reinstall it via <code>pip install --no-cache-dir ...</code></p>

username: xucaojin
cooked: <p>Same thing, maybe the python version? Could the python does not recognize pytorch 1.13?</p>
<pre><code class="lang-auto">C:\...&gt;pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117 --no-cache-dir
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch
  Downloading https://download.pytorch.org/whl/cu117/torch-1.13.1%2Bcu117-cp39-cp39-win_amd64.whl (2255.6 MB)
     ---------------------------------------- 2.3/2.3 GB 3.5 MB/s eta 0:00:00
Requirement already satisfied: torchvision in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (0.12.0)
Requirement already satisfied: torchaudio in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (0.11.0)
Requirement already satisfied: typing-extensions in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from torch) (4.4.0)
Requirement already satisfied: requests in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from torchvision) (2.28.1)
  Downloading torch-1.11.0-cp39-cp39-win_amd64.whl (157.9 MB)
     ---------------------------------------- 157.9/157.9 MB 3.5 MB/s eta 0:00:00
Requirement already satisfied: pillow!=8.3.*,&gt;=5.3.0 in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from torchvision) (9.4.0)
Requirement already satisfied: numpy in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from torchvision) (1.24.1)
Requirement already satisfied: idna&lt;4,&gt;=2.5 in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from requests-&gt;torchvision) (3.4)
Requirement already satisfied: urllib3&lt;1.27,&gt;=1.21.1 in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from requests-&gt;torchvision) (1.26.13)
Requirement already satisfied: certifi&gt;=2017.4.17 in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from requests-&gt;torchvision) (2022.12.7)
Requirement already satisfied: charset-normalizer&lt;3,&gt;=2 in c:\users\...\appdata\local\programs\python\python39\lib\site-packages (from requests-&gt;torchvision) (2.1.1)
Installing collected packages: torch
Successfully installed torch-1.11.0
</code></pre>

username: ptrblck
cooked: <p>Your <code>torchvision</code> and <code>torchaudio</code> versions are too old (<code>0.12.0</code> and <code>0.11.0</code>, respectively, while <code>0.14.1</code> and <code>0.13.1</code> would be needed as seen in my output).<br>
I guess <code>pip</code> finds these packages and downgrades PyTorch again, so uninstall <em>all</em> libs depending on PyTorch and rerun the install command again.<br>
Alternatively, create a new, clean, and empty virtual environment and install the binaries there.</p>