Error in loading tensor/model/input to CUDA

username: v_lab
cooked: <p>I am getting the following error:</p>
<blockquote>
<blockquote>
<blockquote>
<p>import torch<br>
torch.randn(3,3).to(““cuda”)<br>
File “”, line 1<br>
torch.randn(3,3).to(”“cuda”)<br>
^<br>
SyntaxError: unterminated string literal (detected at line 1)<br>
torch.randn(3,3).to(“cuda”)<br>
Traceback (most recent call last):<br>
File “”, line 1, in <br>
RuntimeError: CUDA error: CUDA-capable device(s) is/are busy or unavailable<br>
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.<br>
For debugging consider passing CUDA_LAUNCH_BLOCKING=1<br>
Compile with <code>TORCH_USE_CUDA_DSA</code> to enable device-side assertions.</p>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<blockquote>
<p>torch.cuda.is_available()<br>
True</p>
</blockquote>
</blockquote>
</blockquote>
<p>Even though torch.cuda.is_available() is true and no other processes are running in GPU as shown in nvidia-smi</p>
<p>ue Dec 17 10:07:21 2024<br>
±----------------------------------------------------------------------------------------+<br>
| NVIDIA-SMI 550.127.05             Driver Version: 550.127.05     CUDA Version: 12.4     |<br>
|-----------------------------------------±-----------------------±---------------------+<br>
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |<br>
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |<br>
|                                         |                        |               MIG M. |<br>
|=========================================+========================+======================|<br>
|   0  NVIDIA A10-24Q                 On  |   00000002:00:00.0 Off |                    0 |<br>
| N/A   N/A    P8             N/A /  N/A  |       1MiB /  24512MiB |      0%      Default |<br>
|                                         |                        |                  N/A |<br>
±----------------------------------------±-----------------------±---------------------+</p>
<p>±----------------------------------------------------------------------------------------+<br>
| Processes:                                                                              |<br>
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |<br>
|        ID   ID                                                               Usage      |<br>
|=========================================================================================|<br>
|  No running processes found                                                             |<br>
±----------------------------------------------------------------------------------------+</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="v_lab" data-post="1" data-topic="214301">
<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/v_lab/48/74548_2.png" class="avatar"> v_lab:</div>
<blockquote>
<p>RuntimeError: CUDA error: CUDA-capable device(s) is/are busy or unavailable</p>
</blockquote>
</aside>
<p>Your setup seems to have issues communicating with your GPU. Cou could build any CUDA Sample, execute it, and would most likely see the same issue.<br>
I don’t know if this setups worked before or not, but you could try to e.g. reinstall the driver.</p>

username: v_lab
cooked: <p>Thank you, this setup hasnt worked before. This is a vGPU. I am unable to reset it too.</p>

username: ptrblck
cooked: <p>I don’t know if you might run into the same issue, but check out <a href="https://discuss.pytorch.org/t/nvidia-l40s-48q-and-runtimeerror-cuda-error-operation-not-supported/212716/9">this topic</a> which had similar issues accessing the vGPU.</p>

username: Aknw_Fen
cooked: <p>Strange error but it is showing a typo in the code first:</p>
<pre><code class="lang-auto">torch.randn(3,3).to(”“cuda”)
^
SyntaxError: unterminated string literal (detected at line 1)
torch.randn(3,3).to(“cuda”)
Traceback (most recent call last):
File “”, line 1, in
</code></pre>
<p>PS: Just got now that this is the python runtime environment and those are executions within.</p>
<p>It formatted it very oddly because the <code>&gt;&gt;&gt;</code> means quote block in markdown.</p>

username: ptrblck
cooked: <p>The typo is in <code>""cuda"</code> (note the two <code>"</code> on the left).</p>

username: v_lab
cooked: <p>Yes, I noticed that, that was the first trial . I clearly pasted the corrected commad later.</p>

username: v_lab
cooked: <p>Re-installing the driver solved the problem.</p>