PyTorch CUDA Availability Issue on NVIDIA GeForce MX450

kcwong: <p>Hi there.<br>
Despite having a CUDA-enabled version of PyTorch installed, <code>torch.cuda.is_available()</code> is returning <code>False</code>.<br>
Could I please seek your assistance with this?<br>
Thanks in advance.</p>
<pre><code class="lang-auto">import torch
print("PyTorch version:", torch.__version__)
print("CUDA version:", torch.version.cuda)
print("Is CUDA available:", torch.cuda.is_available())
</code></pre>
<p>When I execute the Python code above in JupyterLab notebook, I get the following output:</p>
<ul>
<li>PyTorch version: 2.2.2+cu121</li>
<li>CUDA version: 12.1</li>
<li>Is CUDA available: False</li>
</ul>
<p>According to the Device Manager on my personal laptop, I have the following specifications:</p>
<ul>
<li>GPU: NVIDIA GeForce MX450</li>
<li>Driver date: August 1, 2021</li>
<li>Driver version: 27.21.14.5774</li>
</ul>
<p>It also states that “The best drivers for your device are already installed”.</p>

ptrblck: <aside class="quote no-group" data-username="kcwong" data-post="1" data-topic="200100">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/k/a5b964/48.png" class="avatar"> kcwong:</div>
<blockquote>
<p>Driver version: 27.21.14.5774</p>
</blockquote>
</aside>
<p>This does not seem to be an NVIDIA driver based on the version, so you might need to reinstall it.</p>

kcwong: <p>Thanks <a class="mention" href="/u/ptrblck">@ptrblck</a> for your reply.<br>
The left snapshot displays the system information from the NVIDIA Control Panel on my laptop. I’ve tried to download several NVIDIA drivers from <a href="https://www.nvidia.com/Download/Find.aspx?lang=en-us#" rel="noopener nofollow ugc">https://www.nvidia.com/Download/Find.aspx?lang=en-us#</a> (middle snapshot), but none of them have passed the compatibility check so far (right snapshot). Additionally, <code>torch.cuda.get_arch_list()</code> returns an empty list <code>[]</code>.<br>
I’m unsure what I might have done incorrectly.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/5/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d" title="Screenshot 2024-04-03 154242"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/5/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d_2_690x257.jpeg" alt="Screenshot 2024-04-03 154242" data-base62-sha1="gOsSjFbBeWVpfQui1c34cViwunz" width="690" height="257" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/5/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d_2_690x257.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/7/5/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d_2_1035x385.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/5/75d72d01b3932a7c5dd1d8c7aaf3d44899d3852d_2_1380x514.jpeg 2x" data-dominant-color="A6A9A3"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot 2024-04-03 154242</span><span class="informations">1920×716 109 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

ptrblck: <p>Once you’ve properly installed a driver, double check that a single PyTorch binary with CUDA support is installed since the current one does not seem to ship with any CUDA kernels and thus returns an empty architecture list.</p>

kcwong: <p>Hi <a class="mention" href="/u/ptrblck">@ptrblck</a>. Thanks again for your response.</p>
<p>I uninstalled the current version of PyTorch and reinstalled it using the following command:</p>
<pre><code class="lang-auto">!pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
</code></pre>
<p>I followed the instructions provided at <a href="https://pytorch.org/get-started/locally/" class="inline-onebox" rel="noopener nofollow ugc">Start Locally | PyTorch</a>.</p>
<p>The following Python code returns <code>True</code>:</p>
<pre><code class="lang-auto">import torch
torch.cuda.is_available()
</code></pre>
<p>Additionally, when I execute the following command:</p>
<pre><code class="lang-auto">torch.cuda.get_arch_list()
</code></pre>
<p>I receive the following output:</p>
<pre><code class="lang-auto">['sm_37', 'sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_90', 'compute_37']
</code></pre>
<pre><code class="lang-auto">print(torch.cuda.get_device_name(0))  # Returns 'GeForce MX450'
</code></pre>
<p>I believe everything is working correctly now.</p>

ptrblck: <p>Yes, now it looks good. Run a quick test by allocating a random tensor on the GPU via <code>torch.randn(1).cuda()</code> and make sure you are able to allocate this tensor.</p>

kcwong: <p>Hi <a class="mention" href="/u/ptrblck">@ptrblck</a> .<br>
When I run <code>torch.randn(1).cuda()</code>, it returns <code>tensor([0.1023], device='cuda:0')</code>.<br>
Thanks for the advice!</p>