Skip to content

"This overload of nonzero is deprecated" #2154

Closed
@LexRillo

Description

@LexRillo

🐛 Bug

A change in torch\nn\functional might have change usability of the nonzero function used in fasterrcnn_resnet50_fpn. This produces a warning and slows down processing.

To Reproduce

Steps to reproduce the behavior:

  1. torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)

Produces the following message
C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.py:2854: UserWarning: The default behavior for interpolate/upsample with float scale_factor will change in 1.6.0 to align with other frameworks/libraries, and use scale_factor directly, instead of relying on the computed output size. If you wish to keep the old behavior, please set recompute_scale_factor=True. See the documentation of nn.Upsample for details.
warnings.warn("The default behavior for interpolate/upsample with float scale_factor will change "
..\torch\csrc\utils\python_arg_parser.cpp:756: UserWarning: This overload of nonzero is deprecated:
nonzero(Tensor input, *, Tensor out)
Consider using one of the following signatures instead:
nonzero(Tensor input, *, bool as_tuple)

Expected behavior

The warning is not expected and there is a considerable slowdown compared with previous iterations. I cannot quantify this properly but I have noticed that a task that took +- 5 minutes now takes more than 10.

Environment

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
  • PyTorch / torchvision Version (e.g., 1.0 / 0.4.0): pytorch 1.5.0 torchvision 0.5.0
  • OS (e.g., Linux): Windows
  • How you installed PyTorch / torchvision (conda, pip, source): conda
  • Build command you used (if compiling from source): conda install pytorch==1.5.0 torchvision==0.5.0 cudatoolkit=10.0 -c pytorch
  • Python version:3.7
  • CUDA/cuDNN version: py3.7_cuda102_cudnn7_0
  • GPU models and configuration:nvidia GeForce GTX 1050
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions