PyTorch 2.0.1 Not Recognizing CUDA 11.4 Despite Correct Environment Setup

username: Wasfia_Nazzal
cooked: <p>Certainly! Here’s a revised message for the PyTorch community that incorporates your latest attempts and findings:</p>
<hr>
<p>Hello PyTorch Community,</p>
<p>I’m encountering an issue where PyTorch (<code>torch.cuda.is_available()</code>) returns <code>False</code>, indicating it does not recognize CUDA on a university server equipped with NVIDIA GPUs, running CUDA 11.4. I have verified CUDA installation with <code>nvidia-smi</code>, which confirms CUDA 11.4 is correctly installed.</p>
<p>Environment Details:</p>
<ul>
<li>CUDA Version:11.4 (verified with <code>nvidia-smi</code>)</li>
<li>PyTorch Version: 2.0.1 (installed using Conda from the <code>pytorch</code> channel)</li>
<li>OS: Linux ubuntu</li>
<li>Python Version: 3.10 (within a Conda environment)</li>
</ul>
<p>Steps Taken:</p>
<ol>
<li>Installed PyTorch 2.0.1 using Conda without specifying <code>cudatoolkit</code> version due to initial <code>PackagesNotFoundError</code> for <code>cudatoolkit=11.4</code>.</li>
<li>Set CUDA-related environment variables correctly:
<ul>
<li><code>CUDA_HOME=/usr/local/cuda-11.4</code></li>
<li><code>LD_LIBRARY_PATH</code> and <code>PATH</code> include CUDA directories.</li>
</ul>
</li>
<li>Verified environment variables (<code>CUDA_HOME</code>, <code>LD_LIBRARY_PATH</code>, <code>PATH</code>) are correctly set.</li>
<li>Restarted the terminal and activated the <code>medsam</code> environment again to ensure changes took effect.</li>
</ol>
<p>Despite these steps, running <code>torch.cuda.is_available()</code> in Python still returns <code>False</code>, suggesting PyTorch does not recognize the CUDA installation.</p>
<p>Questions:</p>
<ol>
<li>Are there known compatibility issues with PyTorch 2.0.1 and CUDA 11.4?</li>
<li>Could the issue be related to how PyTorch was installed or the environment setup?</li>
<li>Are there additional steps I should take to troubleshoot or resolve this issue?</li>
</ol>
<p>Any advice or suggestions would be greatly appreciated. I’m considering building PyTorch from source as a next step but wanted to reach out for any insights or solutions that might not require this.</p>
<p>Thank you!</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="Wasfia_Nazzal" data-post="1" data-topic="196939">
<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/wasfia_nazzal/48/67609_2.png" class="avatar"> Wasfia_Nazzal:</div>
<blockquote>
<p>Installed PyTorch 2.0.1 using Conda without specifying <code>cudatoolkit</code> version due to initial <code>PackagesNotFoundError</code> for <code>cudatoolkit=11.4</code>.</p>
</blockquote>
</aside>
<p>This would mean you’ve installed the CPU-only binary and won’t be able to use your GPU.</p>
<aside class="quote no-group" data-username="Wasfia_Nazzal" data-post="1" data-topic="196939">
<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/wasfia_nazzal/48/67609_2.png" class="avatar"> Wasfia_Nazzal:</div>
<blockquote>
<ul>
<li>Set CUDA-related environment variables correctly:</li>
<li><code>CUDA_HOME=/usr/local/cuda-11.4</code></li>
<li><code>LD_LIBRARY_PATH</code> and <code>PATH</code> include CUDA directories.</li>
<li>Verified environment variables (<code>CUDA_HOME</code>, <code>LD_LIBRARY_PATH</code>, <code>PATH</code>) are correctly set.</li>
</ul>
</blockquote>
</aside>
<p>This doesn’t matter as the PyTorch binaries ship with their own CUDA dependencies. Your locally installed CUDA toolkit will be used if you build PyTorch from source or a custom CUDA extension.</p>
<aside class="quote no-group" data-username="Wasfia_Nazzal" data-post="1" data-topic="196939">
<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/wasfia_nazzal/48/67609_2.png" class="avatar"> Wasfia_Nazzal:</div>
<blockquote>
<p>Are there known compatibility issues with PyTorch 2.0.1 and CUDA 11.4?</p>
</blockquote>
</aside>
<p>No, PyTorch 2.0.1 will work with CUDA 11.4, but you would need to install it from source with CUDA 11.4 as we’ve built the binaries with CUDA 11.7 and 11.8 at that time.</p>

username: Nirmala_Dewi
cooked: <p>Hello PyTorch Community,<br>
I want to install pytorch 2.0.1 using CDA 11.4 what commandline should i use in wheel since the builtin for that version is CUDA 11.7 and 11.8?? if i change the cu117 in the commandline below become cu114, the result ERROR: Could not find a version that satisfies the requirement torch==2.0.1 (fro                                                    m versions: none)<br>
ERROR: No matching distribution found for torch==2.0.1</p>
<pre><code class="lang-auto">pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117
</code></pre>

username: ptrblck
cooked: <p>You could build PyTorch from source with CUDA 11.4 since no binaries were available for this combination, if you really need to use this old CUDA version.</p>

username: Nirmala_Dewi
cooked: <p>I am sorry, I am very begineer, could you explain more by how to do “build PyTorch from source”. Thankyou</p>

username: ptrblck
cooked: <p><a href="https://github.com/pytorch/pytorch?tab=readme-ov-file#from-source">This section</a> of the readme describes how to build PyTorch from source.</p>