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

Chapter 1 first training fails with PyTorch 2 #580

Open
MattTW opened this issue May 11, 2023 · 0 comments
Open

Chapter 1 first training fails with PyTorch 2 #580

MattTW opened this issue May 11, 2023 · 0 comments

Comments

@MattTW
Copy link

MattTW commented May 11, 2023

By default, PyTorch 2.x is now getting pulled in by pip install of fastbook and its dependencies.

This results in an error in the first training exercise:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-8-94c80e27586d>](https://vf2u0v4yexl-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230509-060147-RC00_530563781#) in <cell line: 12>()
     10     label_func=is_cat, item_tfms=Resize(224))
     11 
---> 12 learn = vision_learner(dls, resnet34, metrics=error_rate)
     13 learn.fine_tune(1)

10 frames
[/usr/local/lib/python3.10/dist-packages/torch/serialization.py](https://vf2u0v4yexl-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230509-060147-RC00_530563781#) in persistent_load(saved_id)
   1139             typed_storage = loaded_storages[key]
   1140         else:
-> 1141             nbytes = numel * torch._utils._element_size(dtype)
   1142             typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
   1143 

AttributeError: module 'torch' has no attribute '_utils'

This can be resolved by forcing a downgrade back to PyTorch 1.x in the notebook e.g.:

pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1

Would be good to include a quick troubleshooting note. New users just getting started will be frustrated.

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

1 participant