Okay, I have a short reproduced script. It returns:
tensor(True, device='cuda:0')
tensor(False, device='cuda:0')

on cuda, however not on CPU:
import torch
from torch import nn

class CNN(nn.Module):
    def __init__(self):
        super().__init__()
        self.CNN = nn.Sequential(nn.Conv2d(1, 32, 3, stride=2))

    def forward(self, x):
        return self.CNN(x)

cnn = CNN().to('cuda')
x = torch.full([128, 1, 28, 28], float('nan')).to('cuda')
print(torch.isnan(x).all())
y = cnn(x)
print(torch.isnan(y).all())

On CPU, it returns
tensor(True)
tensor(True)

as expected.