Pytorch error: please report a bug to PyTorch

username: Harsha_J_K
cooked: <p>Hi All,</p>
<p>I am using wsl2 on windows 10 and using PyTorch versions as below:</p>
<p>pytorch                   2.1.0           py3.11_cuda12.1_cudnn8.9.2_0    pytorch<br>
pytorch-cuda              12.1                 ha16c6d3_5    pytorch</p>
<p>I get the following error:</p>
<pre><code class="lang-auto">Starting Training Loop...
torch.Size([128, 3, 128, 128])
Traceback (most recent call last):
  File "/mnt/c/Users/hjakkamk/Downloads/2-ADRL/Assignment/assignment-2/assignment2.py", line 280, in &lt;module&gt;
    errD_real.backward()
  File "/home/hjakkamk/miniconda3/lib/python3.11/site-packages/torch/_tensor.py", line 492, in backward  
    torch.autograd.backward(
  File "/home/hjakkamk/miniconda3/lib/python3.11/site-packages/torch/autograd/__init__.py", line 251, in 
backward
    Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass       
RuntimeError: handle_0 INTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1695392035891/work/c10/cuda/driver_api.cpp":15, please report a bug to PyTorch.
</code></pre>
<p>When I run the code:</p>
<pre><code class="lang-auto">print("Starting Training Loop...")
# For each epoch
for epoch in range(num_epochs):
    # For each batch in the dataloader
    for i, data in enumerate(dataloader, 0):

        ############################
        # (1) Update D network: maximize log(D(x)) + log(1 - D(G(z)))
        ###########################
        ## Train with all-real batch
        netD.zero_grad()
        # Format batch
        real_cpu = data[0].to(device)
        print(real_cpu.shape)
        b_size = real_cpu.size(0)
        # print(b_size)
        label = torch.full((b_size,), real_label, dtype=torch.float, device=device)
        # Forward pass real batch through D
        output = netD(real_cpu).view(-1)
        # print(output.shape)
        # Calculate loss on all-real batch
        errD_real = criterion(output[:batch_size], label)
        # Calculate gradients for D in backward pass
        errD_real.backward()
        D_x = output.mean().item()
</code></pre>
<p>The error is at line errD_real.backward().</p>
<p>Appreciate any help on this. Thanks!</p>

username: ptrblck
cooked: <p>Could you create an issue on GitHub, please?</p>

username: Harsha_J_K
cooked: <p>Can you please provide the exact repo where I need to create this issue? Thanks.</p>

username: ptrblck
cooked: <aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/pytorch/pytorch/issues">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/pytorch/pytorch/issues" target="_blank" rel="noopener">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/344;"><img src="https://opengraph.githubassets.com/f60419811b27473133428c5b9b21b386081f1fc4fdaa348b3cfe03f55822aa75/pytorch/pytorch" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/pytorch/pytorch/issues" target="_blank" rel="noopener">Issues · pytorch/pytorch</a></h3>

  <p>Tensors and Dynamic neural networks in Python with strong GPU acceleration - Issues · pytorch/pytorch</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>