Hi, when I am using torch.use_deterministic_algorithms(True) and I run this code, I got this error.
sum_img are images coverted into a torch tensor of dimension: batch_size x channel x img_size (128x128)
If I move sum_img to cpu instead of cuda, I have got no error
The code gives me error even if I put a number instead a list of number
If I run this code with deterministic algorithms false run without a problem, how can I fix it? thank you in advice
list_n = [0.85,0.5,0.3]
for i in range(3):
channel = sum_img[:,i,:,:]
channel[channel>=5] = list_n[i]
RuntimeError: linearIndex.numel()*sliceSize*nElemBefore == value.numel()INTERNAL ASSERT FAILED at "/pytorch/aten/src/ATen/native/cuda/Indexing.cu":253, please report a bug to PyTorch. number of flattened indices did not match number of elements in the value tensor2684801
Could you post the output of python -m torch.utils.collect_env as well as the shapes for all tensors, please?
Based on the error message it could be a valid error, which we would have to debug and fix (if it’s still observed in the current nightly release).
Hi, I am assuming that you want to make the output of your model deterministic. I had exactly the similar issue in my project and solved it using the following solution:
Avoid use_deterministic_algorithms(True). The above code solved the determinism issue for me. If you run your code on colab, a couple of additional lines are needed, let me know if that is the case so that I can provide it to you.
It’s not sufficient to only seed the code and disable non-deterministic algorithms in cudnn as described in the reproducibility docs, so the suggestion is not a solution.
Do not avoid using torch.use_deterministic_algorithms(True), as it’s the proper way to get a full deterministic code.
In any case, thanks for the additional information. We are tracking the issue here and will fix it.