I want to use torch.cat funcation,But it can't work

This is x’ shape

This is x1’s shape

The tensors with the provided shapes should work fine in torch.cat:

x = torch.randn(1, 128, 32, 160, 160)
x1 = torch.randn(1, 64, 32, 160, 160)
x = torch.cat((x, x1), dim=1)
> torch.Size([1, 192, 32, 160, 160])

Thanks for your help,At the beginning of the code,I write form torch import cat,It can be run in the first few cat operations of the network,But when I debugged to the last cat operation, it stopped working,I don’t know the reason .

when I run train.py in windows , It get error,

when I run train.py in ubuntu, It get error ,

These are all different errors.
The out of memory issue is raised, if your GPU doesn’t have enough memory and you would have to reduce e.g. the batch size.

The second error is raised if you are passing an input tensor to the model, which is too small and a layer would create an empty output tensor (a pooling layer in your case).

PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier. :wink:

thank you very much ,could you tell me how to solve the second error??

You could pass an input with a larger spatial size (height and width) or alternatively remove some pooling layers or other layers, such as strided convs, which would reduce the spatial size too much.

Thank you for your kind answer,this is the same code in different os.I don’t know why x6 can be calculated in windows,image

,but in ubuntu ,it can’t caculate x6.

I don’t know how the model is defined, but one often overlooked difference between different OSes is the sorting of file names, so I guess your might be facing the same issue for a later input.
Feel free to post a reproducible code snippet by wrapping it into three backticks, as mentioned before, so that we can take a look.