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

collection.Iterable is deprecated in Python 3.9+ #1117

Closed
thangngoc89 opened this issue Jun 2, 2023 · 13 comments
Closed

collection.Iterable is deprecated in Python 3.9+ #1117

thangngoc89 opened this issue Jun 2, 2023 · 13 comments
Labels
🐛 Bug Something isn't working

Comments

@thangngoc89
Copy link

🐛 Describe the bug

Any code path that touch this particular line of code (for example trainer.qat)

if isinstance(inputs, collections.Iterable) and not isinstance(inputs, str):

On Python 3.9+, this will have this error

AttributeError: module 'collections' has no attribute 'Iterable'

See this SO answer: https://stackoverflow.com/a/72032097

Versions

Collecting environment information...
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.6 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.27

Python version: 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-4.4.0-143-generic-x86_64-with-glibc2.27
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 525.105.17
cuDNN version: /usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.5
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 16
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 79
Model name: Intel(R) Xeon(R) Platinum 8260M CPU @ 2.40GHz
Stepping: 0
CPU MHz: 2400.000
BogoMIPS: 4800.00
L1d cache: 32K
L1i cache: 32K
L2 cache: 1024K
L3 cache: 36608K
NUMA node0 CPU(s): 0-15
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch invpcid_single kaiser fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap xsaveopt arat

Versions of relevant libraries:
[pip3] numpy==1.23.0
[pip3] pytorch-quantization==2.1.2
[pip3] torch==1.11.0
[pip3] torchmetrics==0.8.0
[pip3] torchvision==0.12.0
[conda] numpy 1.23.0 pypi_0 pypi
[conda] pytorch-quantization 2.1.2 pypi_0 pypi
[conda] torch 1.11.0 pypi_0 pypi
[conda] torchmetrics 0.8.0 pypi_0 pypi
[conda] torchvision 0.12.0 pypi_0 pypi

@BloodAxe BloodAxe added the 🐛 Bug Something isn't working label Jun 2, 2023
@BloodAxe
Copy link
Contributor

BloodAxe commented Jun 2, 2023

This indeed a bug. On 3.9 it raises a warning, on 3.10 it fails with an ImportError.
However the solution is quite simple: collections.Iterable -> typing.Iterable should do the work.
Are you interested in making a PR with a fix? Should be a straightforward fix if you master the signed commits.

@thangngoc89
Copy link
Author

@BloodAxe sure. Thank you for confirming this quickly. I will send a PR tonight

@skyprince999
Copy link

this PR has been merged?

@thangngoc89
Copy link
Author

@skyprince999 sorry. I have loss interests in using yolonas because of the hops I have jumped through to getting started. I tried yolov8 and it’s good enough for my use case

@DoManhQuang
Copy link

DoManhQuang commented Jun 15, 2023

This indeed a bug. On 3.9 it raises a warning, on 3.10 it fails with an ImportError. However the solution is quite simple: collections.Iterable -> typing.Iterable should do the work. Are you interested in making a PR with a fix? Should be a straightforward fix if you master the signed commits.

@BloodAxe Hi,
I tried collections.Iterable -> typing.Iterable but it not work
I tried collections.Iterable -> collections.abc.Iterable then it work
if isinstance(inputs, collections.abc.Iterable) and not isinstance(inputs, str)

@skyprince999
Copy link

This indeed a bug. On 3.9 it raises a warning, on 3.10 it fails with an ImportError. However the solution is quite simple: collections.Iterable -> typing.Iterable should do the work. Are you interested in making a PR with a fix? Should be a straightforward fix if you master the signed commits.

@BloodAxe Hi, I tried collections.Iterable -> typing.Iterable but it not work I tried collections.Iterable -> collections.abc.Iterable then it work if isinstance(inputs, collections.abc.Iterable) and not isinstance(inputs, str)

typing is imported at the start of the file,
from typing import XXXX,XXXx, Iterable

so you need to change it to Iterable

@BloodAxe
Copy link
Contributor

@DoManhQuang Can you please elaborate what error do you get for typing.Iterable and what python version did you test on?

@DoManhQuang
Copy link

Yes, I imported typing and change collections.Iterable -> typing.Iterable and it not work. Now, try again then typing.Iterable is working. I can't reproduce the issue :(
Env: Colab, python 3.10.12

@ferdzo
Copy link

ferdzo commented Jun 15, 2023

How to solve this problem on Kaggle, where we do not have access to the library to edit it?

@DoManhQuang
Copy link

@ferdzo Hi, you can try my way:
1/ git clone https://github.com/Deci-AI/super-gradients.git

2/ change collections.Iterable =>typing.Iterable or collections.abc.Iterable from

if isinstance(inputs, collections.Iterable) and not isinstance(inputs, str):

3/ pip install -r ./super-gradients/requirements.dev.txt

4/ pip install ./super-gradients

@BloodAxe
Copy link
Contributor

It is fixed in master already: #1178
You can expect the next version to be available soon.
Meanwhile you can install SG from master: pip install git+https://github.com/Deci-AI/super-gradients.git

@ferdzo
Copy link

ferdzo commented Jun 16, 2023

@ferdzo Hi, you can try my way: 1/ git clone Deci-AI/super-gradients.git

2/ change collections.Iterable =>typing.Iterable or collections.abc.Iterable from

if isinstance(inputs, collections.Iterable) and not isinstance(inputs, str):

3/ pip install -r ./super-gradients/requirements.dev.txt

4/ pip install ./super-gradients

Well, I've fixed it on my computer and on Colab, because I can access the library and edit it, too much gymnastics to fix it on Kaggle, thanks anyway!

@BloodAxe
Copy link
Contributor

Fixed in 3.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants