Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytorch-quantization example is incompatible with latest torchvision version #3495

Open
spinzello opened this issue Nov 27, 2023 · 5 comments
Assignees
Labels
triaged Issue has been triaged by maintainers

Comments

@spinzello
Copy link

Description

I'm trying to run the following pytorch-quantization example:
tools/pytorch-quantization/examples/calibrate_quant_resnet50.ipynb

The notebook "manually" imports functions from torchvision (without version reference), which seem to have been updated since, thereby leading to an error when running the example.

Specifically, in the "Create data loader" section:

_args = collections.namedtuple('mock_args', ['model', 'distributed', 'cache_dataset'])
dataset, dataset_test, train_sampler, test_sampler = load_data(traindir, valdir, _args(model='resnet50', distributed=False, cache_dataset=False))

I get the following error using the function load_data:
'mock_args' object has no attribute 'val_resize_size'

It seems that the namedtuple _args is expected to have more attributes. I checked out the load_data function and it expects many more attributes besides 'val_resize_size'.

Unless I imported the wrong function or forgot to run another code-block, I'd guess that the example needs to be updated to be compatible with the current torchvision functions. At the very least, the example could point to the version that was used.

This example is referenced in an Nvidia blog. Keeping this up-to-date might help others stumbling upon this.

Environment

TensorRT Version: 8.6.1

Operating System: Windows

Python Version: 3.9.12

PyTorch Version: 2.1.1+cu121

Steps To Reproduce

Run tools/pytorch-quantization/examples/calibrate_quant_resnet50.ipynb

@zerollzeng
Copy link
Collaborator

@ttyio ^ ^

@zerollzeng zerollzeng added the triaged Issue has been triaged by maintainers label Nov 28, 2023
@ttyio
Copy link
Collaborator

ttyio commented Dec 5, 2023

Thanks @SebastianPinzello , we will fixing this!

@Zhang-Wen-chao
Copy link

Thanks @SebastianPinzello , we will fixing this!

Your work is great! When will this bug be fixed?
By the way, will pytorch-quantization add more examples?

@Zhang-Wen-chao
Copy link

vision tag v0.9.0 is ok.

@spinzello
Copy link
Author

It seems that things are moving quite fast in this area and the current modus operandi is to create new tools instead of building on existing ones. Don't expect too much support here. For anyone looking into quantization stuff, the TensorRT Model Optimizer seems to be quite fresh. The section on PyTorch is refactored based on pytorch_quantization. You may find more going on there. Good luck!

TensorRT Tools Overview

Model Optimizer Documentation

Model Optimizer GitHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants