State-of-the-Art Deep Learning scripts organized by models - easy to train and deploy with reproducible accuracy and performance on enterprise-grade infrastructure.
12.93k
stars
3.12k
forks
source link
[Model/Framework] in the model_zoo.py the torch.hub api use wrong #1368
Related to Model/Framework(s)(e.g. GNMT/PyTorch or FasterTransformer/All)
PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/model_zoo.py
Describe the bug
model_zoo.py at the line 10
from torch.hub import _download_url_to_file
must change to
from torch.hub import load_state_dict_from_url as _download_url_to_file
because I read the torch api,The i find the torch.hub did not _download_url_to_file method
only have load_state_dict_from_url
so i rename the _download_url_to_file as load_state_dict_from_url
Expected behavior
A clear and concise description of what you expected to happen.
when I use the pytorch 1.14 (I use the NGC nvcr.io/nvidia/pytorch:23.02-py3 container ),
I use this command :
cd /workspace/object_detection && python -m torch.distributed.launch --nproc_per_node=1 tools/test_net.py --config-file configs/e2e_mask_rcnn_R_50_FPN_1x.yaml --skip-eval DATASETS.TEST "(\"coco_2014_minival\",)" DTYPE float16 OUTPUT_DIR /results TEST.IMS_PER_BATCH 1
the i will get this error:
ImportError: cannot import name '_download_url_to_file' from 'torch.utils.model_zoo' (/usr/local/lib/python3.8/dist-packages/torch/utils/model_zoo.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/test_net.py", line 15, in
from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
File "/workspace/object_detection/maskrcnn_benchmark/utils/checkpoint.py", line 10, in
from maskrcnn_benchmark.utils.model_zoo import cache_url
File "/workspace/object_detection/maskrcnn_benchmark/utils/model_zoo.py", line 10, in
from torch.hub import _download_url_to_file
ImportError: cannot import name '_download_url_to_file' from 'torch.hub' (/usr/local/lib/python3.8/dist-packages/torch/hub.py)
/usr/local/lib/python3.8/dist-packages/torch/distributed/launch.py:180: FutureWarning: The module torch.distributed.launch is deprecated
and will be removed in future. Use torchrun.
Note that --use_env is set by default in torchrun.
If your script expects --local_rank argument to be set, please
change it to read from os.environ['LOCAL_RANK'] instead. See
https://pytorch.org/docs/stable/distributed.html#launch-utility for
further instructions
Environment
Please provide at least:
Container version (e.g. pytorch:19.05-py3):nvcr.io/nvidia/pytorch:23.02-py3
GPUs in the system: (e.g. 8x Tesla V100-SXM2-16GB): NVIDIA A10
CUDA driver version (e.g. 418.67):CUDA Version: 12.0
Related to Model/Framework(s) (e.g. GNMT/PyTorch or FasterTransformer/All) PyTorch/Segmentation/MaskRCNN/pytorch/maskrcnn_benchmark/utils/model_zoo.py Describe the bug model_zoo.py at the line 10 from torch.hub import _download_url_to_file must change to from torch.hub import load_state_dict_from_url as _download_url_to_file
because I read the torch api,The i find the torch.hub did not _download_url_to_file method only have load_state_dict_from_url so i rename the _download_url_to_file as load_state_dict_from_url
ref link: https://pytorch.org/docs/1.10/hub.html https://pytorch.org/docs/1.11/hub.html https://pytorch.org/docs/1.13/model_zoo.html
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen. when I use the pytorch 1.14 (I use the NGC nvcr.io/nvidia/pytorch:23.02-py3 container ),
I use this command : cd /workspace/object_detection && python -m torch.distributed.launch --nproc_per_node=1 tools/test_net.py --config-file configs/e2e_mask_rcnn_R_50_FPN_1x.yaml --skip-eval DATASETS.TEST "(\"coco_2014_minival\",)" DTYPE float16 OUTPUT_DIR /results TEST.IMS_PER_BATCH 1
the i will get this error: ImportError: cannot import name '_download_url_to_file' from 'torch.utils.model_zoo' (/usr/local/lib/python3.8/dist-packages/torch/utils/model_zoo.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "tools/test_net.py", line 15, in
from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
File "/workspace/object_detection/maskrcnn_benchmark/utils/checkpoint.py", line 10, in
from maskrcnn_benchmark.utils.model_zoo import cache_url
File "/workspace/object_detection/maskrcnn_benchmark/utils/model_zoo.py", line 10, in
from torch.hub import _download_url_to_file
ImportError: cannot import name '_download_url_to_file' from 'torch.hub' (/usr/local/lib/python3.8/dist-packages/torch/hub.py)
/usr/local/lib/python3.8/dist-packages/torch/distributed/launch.py:180: FutureWarning: The module torch.distributed.launch is deprecated
and will be removed in future. Use torchrun.
Note that --use_env is set by default in torchrun.
If your script expects
--local_rank
argument to be set, please change it to read fromos.environ['LOCAL_RANK']
instead. See https://pytorch.org/docs/stable/distributed.html#launch-utility for further instructionsEnvironment Please provide at least: