Can't to install PyTorch for CUDA 12.4

Max_Zaikin: <p>Hi Team,</p>
<p>I know my topic looks somehow similar to this one <a href="https://discuss.pytorch.org/t/trying-and-failing-to-install-pytorch-for-cuda-12-0/186194" class="inline-onebox">Trying (and failing) to install PyTorch for CUDA 12.0</a><br>
I tried what is written there and for some reasons it’s not work for me.</p>
<p><strong>Laptop environment setup</strong></p>
<ul>
<li>
<p>Windows 11 with the latest updates</p>
</li>
<li>
<p>Installed CUDA Toolkit cuda_12.4.1_551.78_windows.exe</p>
</li>
<li>
<p>Installed cuDNN 9.0.0 for CUDA 12</p>
</li>
</ul>
<p><strong>Anaconda Environment configuration</strong><br>
conda create --name gpt_env python=3.7<br>
conda activate gpt_env<br>
pip install tensorflow<br>
pip show tensorflow<br>
pip install torch torchvision torchaudio --extra-index-url url is hidden as formum denied to publish more then 2 urls (pytorch/whl/cu121)<br>
pip install transformers<br>
conda install -c conda-forge jupyterlab<br>
conda install -c conda-forge pandas<br>
conda install -c conda-forge seaborn<br>
conda install -c conda-forge matplotlib</p>
<pre><code>conda install -c conda-forge jupyterlab_widgets  
conda install -c conda-forge yipywidgets 
conda install -c conda-forge scikit-learn
</code></pre>
<p><strong>Issue</strong><br>
when I check if PyTorch is available in my Jupiter lab notebook i have False</p>
<pre><code class="lang-auto">print(torch.cuda.is_available()) ---&gt; False
</code></pre>
<p>If I’m trying to install PyTorch as was suggested in topic above i have following error<br>
(gpt_env2) PS C:\Users\NoName&gt; pip install [url hidden]/whl/nightly/cu121/torch-2.1.0.dev20230811%2Bcu121-cp311-cp311-win_amd64.whl<br>
ERROR: torch-2.1.0.dev20230811+cu121-cp311-cp311-win_amd64.whl is not a supported wheel on this platform.</p>
<p>I have to mention that i have Intell based laptop with NVIDIA GPU, so i tried below, and doesn’t work as well<br>
(gpt_env) PS C:\Users\NoName&gt; pip install [url hidden]/whl/nightly/cu121/torch-2.1.0.dev20230811%2Bcu121-cp311-cp311-win_x86_64.whl<br>
ERROR: torch-2.1.0.dev20230811+cu121-cp311-cp311-win_x86_64.whl is not a supported wheel on this platform.</p>
<p>Could you please help me resolve this issue and make PyTorch compiled to work use GPU in the first place</p>
<p>Appreciate your help in advance,<br>
Best regards,<br>
Maks.</p>

Max_Zaikin: <p>Colleagues,</p>
<p>problem solved. The issue was simple I wasn’t read the PyTorch site good enough. Especcialy that part that generates for anaconda command. As of Apr-12-2024, this banner showed that minimum required version of python is &gt;= 3.8, and i was setup my environment for python 3.7. so 2 commands fixed everything:</p>
<ol>
<li>conda create --name my_env python=3.10</li>
<li>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia</li>
</ol>
<p>Then as suggested by <a href="https://discuss.pytorch.org/t/trying-and-failing-to-install-pytorch-for-cuda-12-0/186194/2">ptrblck</a> in <a href="https://discuss.pytorch.org/t/torch-not-compiled-with-cuda-enabled/112467/22" class="inline-onebox">Torch not compiled with CUDA enabled - #22 by ptrblck</a><br>
Run several commands to check if all good:</p>
<pre><code class="lang-auto">1. Python
2. &gt;&gt;&gt; import torch
3. &gt;&gt;&gt; torch.version.cuda
'11.8'
4. &gt;&gt;&gt; torch.__version__
'2.0.0'
5. &gt;&gt;&gt; x = torch.randn(1).cuda()
6. &gt;&gt;&gt; x
tensor([1.7900], device='cuda:0')
</code></pre>
<p>NOTE: Make sure you have installed CUDA 12.1 along with appropriate version of CuDNN</p>

whoab: <p>thank you. so strange, pytorch-cuda 12.4 forces cpu…</p>

HortDog: <p><img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=12" title=":pray:" class="emoji" alt=":pray:" loading="lazy" width="20" height="20"><br>
still works thank you so much</p>

viridityzhu: <p>thank you for this hint!! I’ve struggled with pytorch-cuda=12.4 for a whole day and always got a cpu version. Now I just changed it to 12.1 then everything got fine… what a nightmare…</p>

Monarch: <p>Mine also keeps only using cpu what’s the fix?</p>

Monarch: <p>I don’t understand this solution.</p>
<p><strong>Is Cuda 12.4 just not compatible?</strong></p>

Ivan_Belousov: <p>Hello! Here’s the situation: the NVIDIA Studio driver 565.90 (GTX 1650 Ti) is installed, and PyTorch version 12.4 is installed. When running the command import torch print(torch.cuda.is_available()), it returns False. Everything is directed to the CPU.<br>
What should I do? When checking the version, it shows 2.5.1+cpu. I need PyTorch to direct tasks to the GPU and work with CUDA built into the graphics card driver. Where is the bottleneck, and how can I work around it? Thank you. Heeeeelp   (Windows 10 64) It’s possible that version 12.4 doesn’t support the driver or, conversely, doesn’t support the GPU. Should I install the CUDA Toolkit? If so, which version? Or should I set something in the environment variables? (I’m writing my script in Python 3.10, VS Code) install version 12.1 …  result : [Running] python -u “d:\TRAN v1\CUda.py”<br>
PyTorch is using CPU.<br>
Tensor is allocated on: cpu<br>
2.5.1+cpu</p>

ptrblck: <aside class="quote no-group" data-username="Ivan_Belousov" data-post="8" data-topic="200672">
<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/ivan_belousov/48/73785_2.png" class="avatar"> Ivan_Belousov:</div>
<blockquote>
<p>When checking the version, it shows 2.5.1+cpu</p>
</blockquote>
</aside>
<p>You have installed the CPU-only binary so install a PyTorch binary with CUDA support.</p>

Ivan_Belousov: <p>I installed by this link: pip install torch torchvision torchaudio --index-url <a href="https://download.pytorch.org/whl/cu124" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu124</a> vesion 12.1 the same result <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=12" title=":frowning:" class="emoji" alt=":frowning:" loading="lazy" width="20" height="20"></p>

Ivan_Belousov: <p>Could you please tell me which version supports CUDA? Is it available for download, or do I need to install the CUDA Toolkit?</p>

maffe: <p>I faced the same problem of trying to install pytorch-cuda=12.4 but it kept installing the cpu version. Installing on a fresh environment worked in my case.</p>

ptrblck: <p>You don’t need to install a CUDA toolkit as the PyTorch binaries ship with their own CUDA runtime dependencies.<br>
Select any CUDA version from the install matrix on <a href="http://pytorch.org">pytorch.org</a>, copy/paste the command into your terminal, and execute it.</p>

Soerendip: <p>For some reason I get cuda not available with pytorch 2.5.1, while it works with 2.2.1.</p>

Ray_Mo: <p>I had some problems with pip and used --no-cache-dir option</p>
<p>but not much experience with conda</p>