Hi, I am using colab, pytorch version 1.6.0+cu101. When I try to allocate a model or a parameter to GPU I get the error below. I have tried to reproduce several tips/corrections that were listed in the forum but no one has worked so far…any ideas?
Thanks!
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
print('Using device:', device)
g = nn.Parameter(torch.rand((100,128)), requires_grad=False)
if device.type=='cuda':
  g = g.to(device)
  print(next(g.parameters()).is_cuda) # returns a boolean

Here is the error message:
Using device: cuda
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-35-f9356a863a45> in <module>()
      4 g = nn.Parameter(torch.rand((100,128)), requires_grad=False)
      5 if device.type=='cuda':
----> 6   g = g.to(device)
      7   print(next(g.parameters()).is_cuda) # returns a boolean

RuntimeError: CUDA error: an illegal memory access was encountered