Make GPU available again after numba.cuda.close()?
So when I run cuda.select_device(0) and then cuda.close(). Pytorch cannot access the GPU again, I know that there is way so that PyTorch can utilize the GPU again without having to restart the kernel. But I forgot how. Does anyone else know?
from  numba import cuda as cu
import torch 


# random tensor
a=torch.rand(100,100)

#tensor can be loaded onto the gpu()
a.cuda()

device = cu.get_current_device()
device.reset()

# thows error &quot;RuntimeError: CUDA error: invalid argument&quot;
a.cuda()

cu.close()
# thows error &quot;RuntimeError: CUDA error: invalid argument&quot;
a.cuda()

torch.cuda.is_available()
#True


And then trying to run cuda-based pytorch code yields:
RuntimeError: CUDA error: invalid argument


I had the same issue but with TensorFlow and Keras when iterating through a for loop to tune hyperparamenters. It did not free up the GPU memory used by older models. The cuda solution did not work for me. The following did:
import gc
gc.collect()

