fastbook
fastbook copied to clipboard
Chapter 1 first training fails with PyTorch 2
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.