pytorch / opacus

Training PyTorch models with differential privacy
https://opacus.ai
Apache License 2.0
1.68k stars 338 forks source link

TypeError: 'type' object is not subscriptable #577

Closed GuYueJiahui closed 1 year ago

GuYueJiahui commented 1 year ago

📚 Documentation

When I try to run the example of mnist.py, it raises a error that informs me image

It seems the installed python version (or others library) does not match opacus. Can you give a enviroment guidence?

I have the following enviroment : Python 3.8.13 Package Version


attrs 19.3.0 bleach 3.1.5 brotlipy 0.7.0 certifi 2020.4.5.1 cffi 1.15.0 chardet 3.0.4 charset-normalizer 2.0.4 cryptography 37.0.1 cycler 0.11.0 docutils 0.16 fonttools 4.34.4 functorch 1.13.1 future 0.18.2 idna 2.9 importlib-metadata 1.6.0 jeepney 0.8.0 joblib 1.1.0 keyring 21.2.1 kiwisolver 1.4.4 matplotlib 3.5.2 mkl-fft 1.3.1 mkl-random 1.2.2 mkl-service 2.4.0 more-itertools 8.3.0 numpy 1.18.4 nvidia-cublas-cu11 11.10.3.66 nvidia-cuda-nvrtc-cu11 11.7.99 nvidia-cuda-runtime-cu11 11.7.99 nvidia-cudnn-cu11 8.5.0.96 opacus 1.3.0 opt-einsum 3.3.0 packaging 20.4 Pillow 7.1.2 pip 22.1.2 pkginfo 1.5.0.1 pluggy 0.13.1 protobuf 3.20.3 py 1.8.1 pycparser 2.21 Pygments 2.6.1 pyOpenSSL 22.0.0 pyparsing 2.4.7 PySocks 1.7.1 pytest 5.4.2 python-dateutil 2.8.2 readme-renderer 26.0 requests 2.23.0 requests-toolbelt 0.9.1 scikit-learn 1.1.1 scipy 1.4.1 SecretStorage 3.3.3 setuptools 61.2.0 six 1.14.0 sklearn 0.0 tensorboardX 2.6 threadpoolctl 3.1.0 torch 1.5.0 torchaudio 0.11.0 torchmetrics 0.9.2 torchvision 0.6.0 tqdm 4.46.0 twine 3.1.1 typing_extensions 4.1.1 urllib3 1.25.9 wcwidth 0.1.9 webencodings 0.5.1 wheel 0.37.1 zipp 3.1.0 Hope to get your reply and guidance!

lucacorbucci commented 1 year ago

Hi @GuYueJiahui, I've just tried and it works fine for me on Python 3.8.10. From the error you posted, I would say that you have an error with the type hint.

GuYueJiahui commented 1 year ago

Thank you, the python version is ok. After I update the torch to the version 1.9, the example code can run