Code not compiling, torch not working with CUDA?

seitzy: <p>When I try and run my program I get the error: raise AssertionError(“Torch not compiled with CUDA enabled”) AssertionError: Torch not compiled with CUDA enabled.</p>
<p>nvcc --version returns:</p>
<pre><code class="lang-auto">nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Mar_21_19:24:09_Pacific_Daylight_Time_2021
Cuda compilation tools, release 11.3, V11.3.58
Build cuda_11.3.r11.3/compiler.29745058_0
</code></pre>
<p>and nvidia-sim gives:</p>
<pre><code class="lang-auto">+-----------------------------------------------------------------------------+
| NVIDIA-SMI 511.65       Driver Version: 511.65       CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ... WDDM  | 00000000:01:00.0  On |                  N/A |
|  0%   59C    P2    52W / 225W |   1955MiB /  8192MiB |      3%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
</code></pre>
<p>I don’t know why my CUDA version says 11.6 when I installed 11 .3 through the nvidia site.<br>
I’m not sure why this errors still occuring but print(torch.version.cuda) returns “None” and torch.cuda.is_available() returns “False”.</p>
<p>I installed torch with “conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch”, thanks.</p>

ptrblck: <aside class="quote no-group" data-username="seitzy" data-post="1" data-topic="149345">
<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/seitzy/48/48721_2.png" class="avatar"> seitzy:</div>
<blockquote>
<p>I don’t know why my CUDA version says 11.6 when I installed 11 .3 through the nvidia site.</p>
</blockquote>
</aside>
<p>The reported CUDA version via <code>nvidia-smi</code> depends on the driver and does not necessarily match the installed CUDA toolkit including the compiler.</p>
<aside class="quote no-group" data-username="seitzy" data-post="1" data-topic="149345">
<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/seitzy/48/48721_2.png" class="avatar"> seitzy:</div>
<blockquote>
<p>I’m not sure why this errors still occuring but print(torch.version.cuda) returns “None” and torch.cuda.is_available() returns “False”.<br>
I installed torch with “conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch”, thanks.</p>
</blockquote>
</aside>
<p>I guess the CPU-only release was installed or you have multiple installations in your current conda environment. Check the install logs and make sure the right release is installed and is the only one in your env.</p>

seitzy: <p>Thanks a lot, fixed the issue. My environment had multiple versions installed.</p>

xsgldhy: <p>how do you check whether you have multiple installations? I encounter the same problem with you,  the pytorch is not cpu version, but print(torch.version.cuda) still returns “None”</p>

ptrblck: <aside class="quote no-group" data-username="xsgldhy" data-post="4" data-topic="149345">
<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/xsgldhy/48/70547_2.png" class="avatar"> xsgldhy:</div>
<blockquote>
<p>the pytorch is not cpu version, but print(torch.version.cuda) still returns “None”</p>
</blockquote>
</aside>
<p>This would indicate you’ve installed a CPU-only PyTorch binary. You could uninstall the binaries multiple times to make sure no other PyTorch installation can be found:</p>
<pre data-code-wrap="python"><code class="lang-python">pip uninstall torch -y
pip uninstall torch -y
# repeat until no torch pip wheel can be found

conda uninstall pytorch -y
conda uninstall pytorch -y
# repeat until no pytorch conda binaries can be found
</code></pre>