Can I replace torch.Generator() in this code snippet, as my cuda version is not supported

krishna511: <p>Hi there I am using following code to  create data loaders.</p>
<pre><code class="lang-auto">g_cuda = torch.Generator(device='cuda')
train_set = DataLoader(train_data, batch_size=args.batch_size, shuffle=True, generator = g_cuda)
</code></pre>
<p>and getting this error:<br>
<code>RuntimeError: Device type CUDA is not supported for torch.Generator() api.</code><br>
What is the solution.</p>
<p>Regards</p>

fpozzi: <p>I reproduced your issue, but I did not get any error.</p>
<pre><code class="lang-python">import torch
from torchvision.datasets import MNIST
from torchvision.transforms import ToTensor
from torch.utils.data import DataLoader

generator = torch.Generator(device='cuda')
dataset = MNIST(root=".", download=True, transform=ToTensor())
dt = DataLoader(dataset, batch_size=8, generator=generator, shuffle=True)
</code></pre>
<p>What <code>torch</code> and <code>torchvision</code> versions are you using?</p>

krishna511: <p>torchvision----‘0.9.0’<br>
torch------------‘1.12.0+cpu’</p>
<p>What is the problem?<br>
I have GPU<br>
also can I replace this</p>
<p><code>g_cuda = torch.Generator(device='cuda')</code></p>

fpozzi: <p>I think you need to install cuda versions.</p>
<p>My env:</p>
<pre><code class="lang-auto">torchvision: 0.13.0+cu113
torch: 1.12.0+cu113
</code></pre>

krishna511: <p>can you plz elaborate, how to do it?<br>
I am using windows 10.</p>

AlphaBetaGamma96: <p>When you install PyTorch you need to install <em>with</em> CUDA, as your PyTorch install is CPU only (<code>1.12.0+cpu</code>). You can find the install command for your configuration on the <a href="https://pytorch.org/get-started/locally/" rel="noopener nofollow ugc">get-started</a> page.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/c/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524.png" data-download-href="https://discuss.pytorch.org/uploads/default/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/c/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524_2_690x280.png" alt="image" data-base62-sha1="8G8ZNcAIMgquuSGQy1lgN67RPJG" width="690" height="280" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/c/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524_2_690x280.png, https://discuss.pytorch.org/uploads/default/original/3X/3/c/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/c/3cd4ffc44fa8c4b7b75048126b09e90dccd1f524.png 2x" data-dominant-color="F4DDDA"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">815×331 26.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

krishna511: <p>Actually CUDA-10.2 PyTorch builds are no longer available for Windows.</p>

AlphaBetaGamma96: <p>Then you need to update your drivers which you can do via the NVIDIA control panel. Once you’ve updated to latest version for your GPU you should be able to run 11.6 (assuming your card can support that). But regardless, update the driver and see what’s the maximum support CUDA version for your card which you can find via <code>nvidia-smi</code></p>

krishna511: <p>I have NVIDIA GeForce MX110, can I upgrade it?</p>

AlphaBetaGamma96: <p>Have you tried updating your drivers? It will tell you if you’re up to date or not.</p>