Thanks for the reply.
I tried downgrading PyTorch and CUDA both on my laptop. Just a few hours ago.
I found out that the error was in the mismatch of dimensions between the input and the weights in the Linear layer I was using.
Cosine Similarity, however, is working fine on my laptop. And even in colab. I don’t understand why you are getting this error.
I then upgraded from torch 1.8.1 + cuda 10.2 to torch 1.9.0 + cuda 10.2 and then to cuda 11.1
It is actually working without any errors for now.