Ok, I’ve checked and it seems that data is OK.
I’ve also made something like this in forward pass:
if True in torch.isnan(x) or True in torch.isinf(x):
            if True in torch.isnan(x1) or True in torch.isinf(x1):
                print('image')
                for item in x1:
                    print(item)
            print('image_output')
            for item in x:
                print(item)
        
        if True in torch.isnan(txt) or True in torch.isinf(txt):
            if True in torch.isnan(txt_input) or True in torch.isinf(txt_input):
                print('text')
                for item in txt_input:
                    print(item)
            print('text_output')
            for item in txt:
                print(item)

And it printed:
text_output
torch.tensor(nan, nan, nan, nan (...), device='cuda:0')
(...)
torch.tensor(nan, nan, nan, nan (...), device='cuda:0')

So it seems that input text was OK (without nans or infs), but the text model gave NaNs in all outputs? It is strange, because I’ve done to it this:
for r in self.text.parameters():
     r.requires_grad = False

So in my opinion it shouldn’t take grad - am I right?
What do you think about that? What can cause this problem?