It seems you loaded the images as uint8 and just transformed them into tensors.
If you are using the torchvision.datasets.MNIST data, you can just pass a transformation to it:
dataset = datasets.MNIST(
    root=YOUR_PATH,
    download=False,
    transform=transforms.ToTensor())

Otherwise you should call x = x.float() on the image tensor.