Torch not enabled with CUDA

username: shaheembacker
cooked: <p>I have HP ZBook Fury 16 G10 laptop  with a 12 GB NVIDIA RTX 3500 Ada GPU and I have to use this for my AI project which is written in Python language. I have already installed the CUDA Toolkit 12.8 inside the laptop, which easily recognizes the GPU. But when I load the GPU inside the Python program, the pytorch is unable to recognize the GPU. I use Windows 11.</p>
<p>Note: I have restrictions to install anaconda in my system.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/6/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e" title="cudacheck"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e_2_614x500.jpeg" alt="cudacheck" data-base62-sha1="7OANKslJie4XbsDUOyk8nQicl30" width="614" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/6/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e_2_614x500.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/3/6/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/6/36c74f46b2cc8f9026f6f874cbc80f0c02d9140e.jpeg 2x" data-dominant-color="15141B"><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">cudacheck</span><span class="informations">794×646 71.1 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>
<p>Both nvcc --version command and nvidia-smi command works and shows cuda version 12.8</p>
<p>I have followed the torch installation commands in the pytorch official website:</p>
<p>pip3 install torch torchvision torchaudio --index-url <a href="https://download.pytorch.org/whl/cu128" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu128</a></p>
<p>It installs torch 2.7.0</p>
<p>How to enable torch with cuda inside the python environment?</p>

username: ptrblck
cooked: <p>What does <code>print(torch.version.cuda)</code> return?</p>

username: shaheembacker
cooked: <p>It returns ‘None’.<br>
What might be the real issue? <a class="mention" href="/u/ptrblck">@ptrblck</a></p>

username: ptrblck
cooked: <p>You did not install a PyTorch binary with CUDA dependencies and most likely installed a CPU-only build. Just run <code>pip install torch</code> on Linux (for CUDA 12.6) or select the desired CUDA runtime dependency from our <a href="https://pytorch.org/get-started/locally/">install matrix</a>.</p>

username: shaheembacker
cooked: <aside class="quote no-group" data-username="ptrblck" data-post="4" data-topic="220565">
<div class="title">
<div class="quote-controls"></div>
<img 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>install a PyTorch binary with CUDA dependencies</p>
</blockquote>
</aside>
<p>I use Windows 11. Whenever I run the command from install matrix, it returns requirements already satisfied.</p>

username: ptrblck
cooked: <p>Uninstall all previously installed PyTorch binaries as obviously the CPU-only binary is still found and used.</p>

username: shaheembacker
cooked: <p>I have figured out the real problem. This was my work PC which have security guidelines regarding installation of PIP packages in Python. My  company had their own repository for PyPi packages and I index this link during pip installations. When I went into the repository, I found that all the torch installations available in the company repo are CPU binaries. So, even if i use the command to install CUDA binary, only CPU binary was being installed.</p>
<p>So I have installed the pip packages from my home network without connecting to company VPN. <img src="https://discuss.pytorch.org/images/emoji/apple/innocent.png?v=14" title=":innocent:" class="emoji" alt=":innocent:" loading="lazy" width="20" height="20"> This directly installed torch compiled with CUDA.</p>
<p>Thank you very much for all the help. <img src="https://discuss.pytorch.org/images/emoji/apple/heart_eyes.png?v=14" title=":heart_eyes:" class="emoji" alt=":heart_eyes:" loading="lazy" width="20" height="20"><br>
May Allah bless and guide you. <img src="https://discuss.pytorch.org/images/emoji/apple/palms_up_together.png?v=14" title=":palms_up_together:" class="emoji" alt=":palms_up_together:" loading="lazy" width="20" height="20"></p>