GPU is not available for Pytorch

Herlasser: <p>Hi to everyone,<br>
I probably have some some compatibility problem between the versions of CUDA and PyTorch.<br>
I can’t use the GPU and everytime I ran the command <em>torch.cuda.is_available()</em> the result is always <em>FALSE.</em></p>
<p>I’m using Anaconda (on Windows 11) and I have tried many things (such as upgrading and downgrading variuos versions), but nothing has worked.</p>
<p>I have a GeForce MX150 and currently my versions are:<br>
CUDA Version: 11.6<br>
PyTorch Version: 1.13.1<br>
Python  Version 3.9.13</p>
<p>Thank you all</p>

ptrblck: <p>I have the same GPU in my Windows laptop and the <code>1.3.1+cu117</code> wheels work fine for me:</p>
<pre><code class="lang-python">&gt;&gt;&gt; import torch
&gt;&gt;&gt; torch.__version__
'1.13.1+cu117'
&gt;&gt;&gt; torch.cuda.is_available()
True
&gt;&gt;&gt; torch.cuda.get_device_properties(0)
_CudaDeviceProperties(name='GeForce MX150', major=6, minor=1, total_memory=2048MB, multi_processor_count=3)
&gt;&gt;&gt; torch.randn(1).cuda()
tensor([-0.9126], device='cuda:0')
</code></pre>

Herlasser: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="174440">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p><code>torch.randn(1).cuda()</code></p>
</blockquote>
</aside>
<p>Thank you for your answer.<br>
Unfortunatelly, there seams that the ‘1.13.1+cu117’ version doesn’t work with conda, but  only with pip. Did you used pip or conda to install it?</p>
<p>Thank you again.</p>

Herlasser: <p>After many attempts I managed to get things working (I don’t know exactly how and why).</p>
<p>I report some passages here if they might be of use to someone.</p>
<p>1)Open anaconda prompt as administrator.</p>
<p>2)Remove everything:</p>
<pre><code class="lang-auto">conda remove pytorch torchvision torchaudio cudatoolkit
conda clean --all
</code></pre>
<p>3)Instal things separately and activating tensorflow-gpu:</p>
<pre><code class="lang-auto">conda install -c anaconda cudatoolkit
</code></pre>
<pre><code class="lang-auto">conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu
</code></pre>
<p>4)Instal PyTorch (GPU version compatible with CUDA verison):</p>
<pre><code class="lang-auto">conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
</code></pre>

Tintwotin: <p>I’m having the same problem with 2.0.0 as mentioned above, however the <code>torch==1.3.1+cu117</code> doesn’t seem to work anymore:</p>
<blockquote>
<p>ERROR: Could not find a version that satisfies the requirement torch==1.3.1+cu117 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0)<br>
ERROR: No matching distribution found for torch==1.3.1+cu117</p>
</blockquote>

ptrblck: <p><code>1.3.1+cu117</code> isn’t a valid build and I assume you want to install <code>1.13.1+cu117</code>.<br>
In any case I would still recommend installing the latest stable release instead of trying to fall back.</p>

Tintwotin: <p>Sorry, same error with 1.13.1+cu117:</p>
<pre><code class="lang-auto">ERROR: Could not find a version that satisfies the requirement torch==1.13.1+cu117 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0)
ERROR: No matching distribution found for torch==1.13.1+cu117
</code></pre>
<p>Installing 2.0.0&amp;1.13.1 gives me AssertionError: Torch not compiled with CUDA enabled.<br>
Previously, it couldn’t detect the CUDA of my RTX 2060. Spend two weeks on this.</p>

ptrblck: <p>Both versions work for me if I stick to the install instructions:</p>
<pre><code class="lang-python">pip install torch
Collecting torch
  Downloading torch-2.0.0-cp38-cp38-manylinux1_x86_64.whl (619.9 MB)
...
pip install torch==1.13.1
Collecting torch==1.13.1
  Downloading torch-1.13.1-cp38-cp38-manylinux1_x86_64.whl (887.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 887.4/887.4 MB 58.5 MB/s eta 0:00:00
Collecting typing-extensions
  Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB)
Collecting nvidia-cudnn-cu11==8.5.0.96
  Downloading nvidia_cudnn_cu11-8.5.0.96-2-py3-none-manylinux1_x86_64.whl (557.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 557.1/557.1 MB 58.4 MB/s eta 0:00:00
Collecting nvidia-cuda-runtime-cu11==11.7.99
  Downloading nvidia_cuda_runtime_cu11-11.7.99-py3-none-manylinux1_x86_64.whl (849 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 849.3/849.3 kB 79.3 MB/s eta 0:00:00
Collecting nvidia-cublas-cu11==11.10.3.66
  Downloading nvidia_cublas_cu11-11.10.3.66-py3-none-manylinux1_x86_64.whl (317.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 317.1/317.1 MB 58.4 MB/s eta 0:00:00
Collecting nvidia-cuda-nvrtc-cu11==11.7.99
  Downloading nvidia_cuda_nvrtc_cu11-11.7.99-2-py3-none-manylinux1_x86_64.whl (21.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.0/21.0 MB 58.5 MB/s eta 0:00:00
...
pip install torch==1.13.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch==1.13.1+cu117
  Downloading https://download.pytorch.org/whl/cu117/torch-1.13.1%2Bcu117-cp38-cp38-linux_x86_64.whl (1801.8 MB)
</code></pre>