Background: I have a perfectly functional jupyter notebook that until now has been running only on my local machine (using cpu). A colleague recently told me about Google Colab, and claimed I could run the code there with minimal changes, with the advantage of allowing gpu computation.
Problem: Google Colab throws errors all over the place, independently of whether I run it on cpu or gpu. The first of them is:
     15     def forward(self, x):
---> 16         prod = torch.mm(x, self.weights.t())  # Wx
     17         return torch.add(prod, self.bias)     # Wx+b

RuntimeError: self must be a matrix

Again, the code works perfectly fine on my local machine, and the error appears regardless of whether I run Colab on cpu or gpu. It’s as if Colab doesn’t know PyTorch, but there were no errors upon importing.
I’m sure I must be missing something incredibly obvious, but I cannot seem to find a similar issue online. Can anyone shed light on why the code breaks on Colab? (Please don’t tell me one is expected to refactor the entire notebook in some Colab-specific way; that would negate the time-savings of using it in the first place!)