Your code is working on the CPU, if you specify requires_grad=True for self.kernel or just remove the requires_grad argument, since the default is set to True for nn.Parameter.
It’s still strange, that your code threw an error on my machine using the GPU.