NVIDIA / NVIDIA/TensorRT

pytorch-quantization example is incompatible with latest torchvision version

Open
#3,495 5 comments 0 reactions 1 assignee View on GitHub

@ttyio is already working on this.

Since Nov 28, 2023.

triaged
Dominant language
C++
Stars
13.4k
Forks
2.4k
Avg merge
5d 3h
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.