Skip to content

AttributeError: module 'torchvision.ops._utils' has no attribute 'split_normalization_params' #5456

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

Closed
etetteh opened this issue Feb 22, 2022 · 6 comments

Comments

@etetteh
Copy link

etetteh commented Feb 22, 2022

🐛 Describe the bug

Currently using torchvision==0.11.3, and following the training recipe [here](https://github.com/pytorch/vision/blob/main/references/classification/train.py). I get the following error, and by looking at the methods in the version of torchvision I have, it isn't available. The Nightly` version doesn't contain it either.

Traceback (most recent call last):
  File "/Users/en_tetteh/miniforge3/envs/venv_ivadomed/bin/ivadomed", line 33, in <module>
    sys.exit(load_entry_point('ivadomed', 'console_scripts', 'ivadomed')())
  File "/Users/en_tetteh/NEUROPOLY/ivadomed/ivadomed/main.py", line 593, in run_main
    run_command(context=context,
  File "/Users/en_tetteh/NEUROPOLY/ivadomed/ivadomed/main.py", line 429, in run_command
    best_training_dice, best_training_loss, best_validation_dice, best_validation_loss = imed_training.train(
  File "/Users/en_tetteh/NEUROPOLY/ivadomed/ivadomed/training.py", line 117, in train
    param_groups = torchvision.ops._utils.split_normalization_params(model)
AttributeError: module 'torchvision.ops._utils' has no attribute 'split_normalization_params'

Versions

Collecting environment information...
PyTorch version: 1.10.2
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.2.1 (arm64)
GCC version: Could not collect
Clang version: 13.0.0 (clang-1300.0.29.30)
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.10 | packaged by conda-forge | (main, Feb 1 2022, 21:25:34) [Clang 11.1.0 ] (64-bit runtime)
Python platform: macOS-12.2.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.22.2
[pip3] torch==1.10.2
[pip3] torchio==0.18.73
[pip3] torchvision==0.11.3
[conda] cpuonly 1.0 0 pytorch-nightly
[conda] numpy 1.22.2 py39h61a45d2_0 conda-forge
[conda] torch 1.10.2 pypi_0 pypi
[conda] torchio 0.18.73 pypi_0 pypi
[conda] torchvision 0.11.3 pypi_0 pypi

@datumbox
Copy link
Contributor

The problem is you are using the latest training scripts on main branch with and old torchvision version (0.11.3). This method does not exist on 0.11.3. I've added it in late October last year which was past the branch cut for v0.11 (see #4493). I'm pretty sure you will find it on the latest nightly of torchvision because its been on our main branch for months.

I recommend to check again the versions that you are using when installing the nightly. I'll close the issue but if you face more problems let me know.

@etetteh
Copy link
Author

etetteh commented Feb 23, 2022

@datumbox Thank you for your response. I installed the latest nightly, and also the installation from dev but still not available. Anyways, I have created a utils file and referenced the main branch.

When following the recipe in Phase 1 (classification), when implementing one of the recipes, say long training, is the model initial with the weights from lr optimization, or is it always trained from scratch? Thank you, and your response is really needed.

@datumbox
Copy link
Contributor

@etetteh As far as I can tell, the method exists on nightly. Just download this and unzip it and look for the method in the folder. You will see that it is part of the _utils.py file. I think it's more likely that you don't use the version you install due to issues on your environment.

Concerning your questions about the recipe, I'm not sure to which recipe you refer. It's also not clear to me what you mean by "is the model initial with the weights from lr optimization". If you mean how the models in TorchVision are trained, then we train all the classification models from scratch.

@etetteh
Copy link
Author

etetteh commented Feb 23, 2022

@datumbox okay, I guess maybe my environment is not using the installed nightly version.

My question was whether the models are initialized with the weights of the previous item on the recipe. For example, there are

  1. LR optimizations
  2. TrivialAugment
  3. Long Training
  4. Random Erasing
    .
    .
    .
  1. Repeated Augmentation **

What I was asking was, assuming you run Step 1 (LR optimizations), is Step 2 trained from scratch or it is initialized with the weights from Step 1.

@datumbox
Copy link
Contributor

The article does not describe a step by step process on how to train the models but rather explains on high level how the recipe was discovered. If you want to use the recipe, just use the command available on the article and you are good to go.

@etetteh
Copy link
Author

etetteh commented Feb 23, 2022

Okay. Thank you so much. I was following the article because I am using the recipe for research and wanted to know how the various parts contribute to the overall metric just as in the article.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants