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

AttributeError: module 'typing' has no attribute '_ClassVar' #8011

Closed
yllgl opened this issue Jun 17, 2021 · 1 comment
Closed

AttributeError: module 'typing' has no attribute '_ClassVar' #8011

yllgl opened this issue Jun 17, 2021 · 1 comment
Labels
bug Something isn't working help wanted Open to be worked on

Comments

@yllgl
Copy link

yllgl commented Jun 17, 2021

🐛 Bug

After I upgrade my pytorch_lightning version to 1.3.5, this error occurs when I try to import pytorch_lightning in my code.

Environment

  • CUDA:
    - GPU:
    - Tesla K80
    - Tesla K80
    - Tesla K80
    - Tesla K80
    - available: True
    - version: 10.2
  • Packages:
    - numpy: 1.19.4
    - pyTorch_debug: True
    - pyTorch_version: 1.7.0
    - pytorch-lightning: 1.3.5
    - tqdm: 4.47.0
  • System:
    - OS: Linux
    - architecture:
    - 64bit
    - ELF
    - processor: x86_64
    - python: 3.8.3
    - version: Thanks for sharing! #2 SMP Mon Apr 23 15:52:50 CST 2018

Additional context

Python 3.8.3 (default, Jul  2 2020, 16:21:59)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytorch_lightning
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/__init__.py", line 21, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/callbacks/__init__.py", line 26, in <module>
    from pytorch_lightning.callbacks.stochastic_weight_avg import StochasticWeightAveraging
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/callbacks/stochastic_weight_avg.py", line 26, in <module>
    from pytorch_lightning.trainer.optimizers import _get_default_scheduler_config
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/__init__.py", line 18, in <module>
    from pytorch_lightning.trainer.trainer import Trainer
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 25, in <module>
    from pytorch_lightning.accelerators import Accelerator
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/accelerators/__init__.py", line 13, in <module>
    from pytorch_lightning.accelerators.accelerator import Accelerator  # noqa F401
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 25, in <module>
    from pytorch_lightning.plugins.precision import ApexMixedPrecisionPlugin, NativeMixedPrecisionPlugin, PrecisionPlugin
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/__init__.py", line 2, in <module>
    from pytorch_lightning.plugins.plugins_registry import (  # noqa: F401
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/plugins_registry.py", line 21, in <module>
 from pytorch_lightning.trainer.optimizers import _get_default_scheduler_config
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/__init__.py", line 18, in <module>
    from pytorch_lightning.trainer.trainer import Trainer
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 25, in <module>
    from pytorch_lightning.accelerators import Accelerator
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/accelerators/__init__.py", line 13, in <module>
    from pytorch_lightning.accelerators.accelerator import Accelerator  # noqa F401
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 25, in <module>
    from pytorch_lightning.plugins.precision import ApexMixedPrecisionPlugin, NativeMixedPrecisionPlugin, PrecisionPlugin
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/__init__.py", line 2, in <module>
    from pytorch_lightning.plugins.plugins_registry import (  # noqa: F401
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/plugins_registry.py", line 21, in <module>
    from pytorch_lightning.plugins.training_type.training_type_plugin import TrainingTypePlugin
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/__init__.py", line 3, in <module>
    from pytorch_lightning.plugins.training_type.ddp_spawn import DDPSpawnPlugin  # noqa: F401
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/ddp_spawn.py", line 30, in <module>
    from pytorch_lightning.trainer.states import TrainerFn
  File "/THL5/home/hugpu1/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/states.py", line 80, in <module>
    class TrainerState:
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 958, in dataclass
    return wrap(_cls)
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 800, in _process_class
    cls_fields = [_get_field(cls, name, type)
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 800, in <listcomp>
    cls_fields = [_get_field(cls, name, type)
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 659, in _get_field
    if (_is_classvar(a_type, typing)
  File "/THL5/software/pytorch/1.7.0-cu102-py38/dataclasses.py", line 550, in _is_classvar
    return type(a_type) is typing._ClassVar
AttributeError: module 'typing' has no attribute '_ClassVar'
@yllgl yllgl added bug Something isn't working help wanted Open to be worked on labels Jun 17, 2021
@yllgl yllgl changed the title RuntimeError: CUDA error: invalid device ordinal AttributeError: module 'typing' has no attribute '_ClassVar' Jun 18, 2021
@yllgl
Copy link
Author

yllgl commented Jun 18, 2021

I upgrade pytorch version and it solves my problem.

@yllgl yllgl closed this as completed Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on
Projects
None yet
Development

No branches or pull requests

1 participant