Solved by Bobby_Joe_Hill in post #2 
              
              
                I think I found the problem: If I cast the numpy arrays img and seg as int64 directly there is no error occuring anymore. 
NIFTI images can potentially have float values. torch.stack could not cast the inputs to the right datatype, giving an error. 
With this code I can reproduce the error: 
from to…