torch meshgrid warning: in an upcoming release, it will be required to pass the indexing argument

23.6k Views Asked by At

I am trying to execute LIIF(https://github.com/yinboc/liif) and the following warning appears:

/usr/local/lib/python3.7/dist-packages/torch/functional.py:445: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  ../aten/src/ATen/native/TensorShape.cpp:2157.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
3

There are 3 best solutions below

0
Fang WU On

My answer might not be the direct solution, but can be somehow relevant. I met the same warning but it was caused by calling torch.cartesian_prod(*tensors).

/opt/conda/lib/python3.7/site-packages/torch/functional.py:1069: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at  /opt/conda/conda-bld/pytorch_1634272168290/work/aten/src/ATen/native/TensorShape.cpp:2157.)return _VF.cartesian_prod(tensors)  # type: ignore[attr-defined]

From my personal experience, I could not find any relatives between _VF.cartesian_prod and meshgrid, but the warning is there. Some other guys have encountered this, and see pytorch issue #50276. The engineer from Pytorch promised to take a look at it, but I guess they may ignore (or perhaps forget) this.

So I believe this may not be a serious problem and hinder the usage of Pytorch. Just go ahead with it and see whether in the future release, any new arguments (e.g., index) are needed.

0
FreeToGo On

Change it to

return _VF.meshgrid(tensors, **kwargs, indexing="ij")
0
Aknur Karabay On

I changed the pytorch version to 22.10 nvcr.io/nvidia/pytorch:22.10-py3 and it helped to resolve the issue. It appeared while I was training yolov8.