AttributeError: 'AvgPool3d' object has no attribute '__flops__'
See original GitHub issueThanks for your error report and we appreciate it a lot. If you feel we have help you, give us a STAR! 😆
Checklist
- I have searched related issues but cannot get the expected help.
- The bug has not been fixed in the latest version.
Describe the bug
I was trying to get the FLOPs of the tpn_imagenet_pretrained_slowonly_r50_8x8x1_150e_kinetics_rgb model but I encountered this AttributeError. And it seems like the AvgPool3d module wasn’t properly added the __flops__ attribute.
Reproduction
- What command or script did you run?
python tools/analysis/get_flops.py configs/recognition/tpn/tpn_imagenet_pretrained_slowonly_r50_8x8x1_150e_kinetics_rgb.py --shape 1 3 8 340 256
- Did you make any modifications on the code or config? Did you understand what you have modified?
No
- What dataset did you use?
Kinetics-400. But it doesn’t matter here.
Environment
sys.platform: linux
Python: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:18) [GCC 10.3.0]
CUDA available: True
GPU 0,1,2,3,4,5,6,7: Tesla V100-SXM2-32GB
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 11.6, V11.6.124
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
PyTorch: 1.10.2
PyTorch compiling details: PyTorch built with:
- GCC 7.3
- C++ Version: 201402
- Intel(R) oneAPI Math Kernel Library Version 2022.1-Product Build 20220311 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX512
- CUDA Runtime 11.3
- NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
- CuDNN 8.2
- Magma 2.5.2
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.2, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,
TorchVision: 0.11.3
OpenCV: 4.6.0
MMCV: 1.6.0
MMCV Compiler: GCC 9.3
MMCV CUDA Compiler: 11.3
MMAction2: 0.24.0+7fca5b6
Error traceback
If applicable, paste the error traceback here.
Traceback (most recent call last):
File "tools/analysis/get_flops.py", line 73, in <module>
main()
File "tools/analysis/get_flops.py", line 63, in main
flops, params = get_model_complexity_info(model, input_shape)
File "/home/ubuntu/.conda/envs/open-mmlab/lib/python3.8/site-packages/mmcv/cnn/utils/flops_counter.py", line 108, in get_model_complexity_info
flops_count, params_count = flops_model.compute_average_flops_cost()
File "/home/ubuntu/.conda/envs/open-mmlab/lib/python3.8/site-packages/mmcv/cnn/utils/flops_counter.py", line 356, in compute_average_flops_cost
flops_sum += module.__flops__
File "/home/ubuntu/.conda/envs/open-mmlab/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1177, in __getattr__
raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'AvgPool3d' object has no attribute '__flops__'
Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
[BUG] AttributeError: 'NewGELUActivation' object has no ...
... it throws AttributeError: 'NewGELUActivation' object has no attribute 'flops' To Reproduce ./test_tune.sh tune Expected behavior...
Read more >'AvgPool2d' object has no attribute 'divisor_override'
AttributeError : 'AvgPool2d' object has no attribute 'divisor_override' - PyTorch Forums.
Read more >AttributeError: 'ReLU' object has no attribute 'dim'
nn.ReLU() creates an nn.Module which you can add e.g. to an nn.Sequential model. nn.functional.relu on the other side is just the functional ...
Read more >PyTorchVideo Documentation
PyTorchVideo provide default builders to construct state-of-the-art video understanding models, layers, heads, and losses. 1.1.1 Models. You can ...
Read more >Pytorch classifier error AttributeError: 'Linear' object has no ...
Hello, after upgrading to deeppavlov 0.16, I get the following error with some models that were previously working (e.g. ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I submitted this issue to mmcv @coldmanck
This code was written by another colleague one year ago. Give me sometime to figure out the logic.