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

ImportError: cannot import name '_module_available' from 'pytorch_lightning.utilities' #15491

Closed
Pedrexus opened this issue Nov 3, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@Pedrexus
Copy link

Pedrexus commented Nov 3, 2022

Bug description

I just updated PL today and have been getting ImportError when trying to import PL Bolts classes. I noticed the _module_available function has been removed from PL 1.8 pytorch_lightning.utilities, so I'm not sure the best way to propose a fix. Is there a work around?

Traceback (most recent call last):
    import pl_bolts.datamodules.cifar10_datamodule
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/__init__.py", line 11, in <module>
    from pl_bolts import (  # noqa: E402
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/callbacks/__init__.py", line 3, in <module>
    from pl_bolts.callbacks.data_monitor import ModuleDataMonitor, TrainingDataMonitor
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/callbacks/data_monitor.py", line 13, in <module>
    from pl_bolts.utils import _WANDB_AVAILABLE
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/utils/__init__.py", line 8, in <module>
    from pytorch_lightning.utilities import _module_available
ImportError: cannot import name '_module_available' from 'pytorch_lightning.utilities' (/opt/conda/lib/python3.8/site-packages/pytorch_lightning/utilities/__init__.py)

Thank you very much for the excellent work on this library!

How to reproduce the bug

With lightning and pl_bolts installed, run `import pl_bolts.datamodules.cifar10_datamodule`

Error messages and logs

Traceback (most recent call last):
    import pl_bolts.datamodules.cifar10_datamodule
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/__init__.py", line 11, in <module>
    from pl_bolts import (  # noqa: E402
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/callbacks/__init__.py", line 3, in <module>
    from pl_bolts.callbacks.data_monitor import ModuleDataMonitor, TrainingDataMonitor
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/callbacks/data_monitor.py", line 13, in <module>
    from pl_bolts.utils import _WANDB_AVAILABLE
  File "/opt/conda/lib/python3.8/site-packages/pl_bolts/utils/__init__.py", line 8, in <module>
    from pytorch_lightning.utilities import _module_available
ImportError: cannot import name '_module_available' from 'pytorch_lightning.utilities' (/opt/conda/lib/python3.8/site-packages/pytorch_lightning/utilities/__init__.py)

Environment

* CUDA:
        - GPU:
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
                - Tesla V100-SXM2-16GB
        - available:         True
        - version:           11.8
* Lightning:
        - botorch:           0.5.0
        - functorch:         0.3.0a0
        - gpytorch:          1.9.0
        - lightning-bolts:   0.5.0
        - lightning-lite:    1.8.0.post1
        - lightning-utilities: 0.3.0
        - pytorch-lightning: 1.7.7
        - pytorch-quantization: 2.1.2
        - pytorch-ranger:    0.1.1
        - torch:             1.13.0a0+d0d6b1f
        - torch-optimizer:   0.3.0
        - torch-tb-profiler: 0.4.0
        - torch-tensorrt:    1.3.0a0
        - torchmetrics:      0.9.3
        - torchtext:         0.11.0a0
        - torchvision:       0.14.0a0
* Packages:
        - absl-py:           1.2.0
        - aiohttp:           3.8.3
        - aiosignal:         1.2.0
        - alabaster:         0.7.12
        - antlr4-python3-runtime: 4.9.3
        - anyio:             3.6.1
        - apex:              0.1
        - appdirs:           1.4.4
        - argon2-cffi:       21.3.0
        - argon2-cffi-bindings: 21.2.0
        - asttokens:         2.0.8
        - async-timeout:     4.0.2
        - attrs:             22.1.0
        - audioread:         3.0.0
        - ax-platform:       0.2.0
        - babel:             2.10.3
        - backcall:          0.2.0
        - backports.functools-lru-cache: 1.6.4
        - beautifulsoup4:    4.11.1
        - bleach:            5.0.1
        - blis:              0.7.8
        - botorch:           0.5.0
        - braceexpand:       0.1.7
        - brotlipy:          0.7.0
        - cachetools:        5.2.0
        - calcifer:          0.1.0
        - catalogue:         2.0.8
        - certifi:           2022.9.24
        - cffi:              1.15.1
        - cfgv:              3.3.1
        - chardet:           5.0.0
        - charset-normalizer: 2.1.0
        - click:             8.1.3
        - cloudpickle:       2.2.0
        - codecov:           2.1.12
        - colorama:          0.4.5
        - colorlog:          6.7.0
        - commonmark:        0.9.1
        - conda:             22.9.0
        - conda-build:       3.22.0
        - conda-package-handling: 1.9.0
        - contourpy:         1.0.5
        - coolname:          1.1.0
        - coverage:          6.5.0
        - cryptography:      38.0.2
        - cuda-python:       11.7.0+0.g95a2041.dirty
        - cudf:              22.8.0a0+304.g6ca81bbc78.dirty
        - cugraph:           22.8.0a0+132.g2daa31b6.dirty
        - cuml:              22.8.0a0+52.g73b8d00d0.dirty
        - cupy-cuda118:      11.0.0
        - cycler:            0.11.0
        - cymem:             2.0.6
        - cython:            0.29.32
        - dask:              2022.7.1
        - dask-cuda:         22.8.0a0+36.g9860cad
        - dask-cudf:         22.8.0a0+304.g6ca81bbc78.dirty
        - dataclasses:       0.8
        - debugpy:           1.6.3
        - decorator:         5.1.1
        - deepspeed:         0.7.4
        - defusedxml:        0.7.1
        - distlib:           0.3.6
        - distributed:       2022.7.1
        - docstring-parser:  0.15
        - docutils:          0.17.1
        - entrypoints:       0.3
        - exceptiongroup:    1.0.0
        - executing:         1.1.1
        - expecttest:        0.1.3
        - fairscale:         0.4.12
        - fastjsonschema:    2.16.2
        - fastrlock:         0.8
        - filelock:          3.8.0
        - fire:              0.4.0
        - flake8:            3.7.9
        - flask:             2.2.2
        - fonttools:         4.37.4
        - frozenlist:        1.3.1
        - fsspec:            2022.8.2
        - functorch:         0.3.0a0
        - future:            0.18.2
        - glances:           3.3.0.2
        - glob2:             0.7
        - google-auth:       2.12.0
        - google-auth-oauthlib: 0.4.6
        - gpytorch:          1.9.0
        - graphsurgeon:      0.4.6
        - grpcio:            1.49.1
        - heapdict:          1.0.1
        - hjson:             3.1.0
        - hydra-ax-sweeper:  1.2.0
        - hydra-colorlog:    1.2.0
        - hydra-core:        1.3.0.dev0
        - hydra-joblib-launcher: 1.2.0
        - hypothesis:        4.50.8
        - identify:          2.5.8
        - idna:              3.3
        - imagesize:         1.4.1
        - importlib-metadata: 5.0.0
        - importlib-resources: 5.10.0
        - iniconfig:         1.1.1
        - iopath:            0.1.10
        - ipykernel:         6.16.0
        - ipython:           8.5.0
        - ipython-genutils:  0.2.0
        - itsdangerous:      2.1.2
        - jedi:              0.18.1
        - jinja2:            3.1.2
        - joblib:            1.2.0
        - json5:             0.9.10
        - jsonschema:        4.7.2
        - jupyter-client:    7.4.2
        - jupyter-core:      4.11.1
        - jupyter-server:    1.21.0
        - jupyter-tensorboard: 0.2.0
        - jupyterlab:        2.3.2
        - jupyterlab-pygments: 0.2.2
        - jupyterlab-server: 1.2.0
        - jupytext:          1.14.1
        - kiwisolver:        1.4.4
        - langcodes:         3.3.0
        - libarchive-c:      4.0
        - librosa:           0.9.2
        - lightning-bolts:   0.5.0
        - lightning-lite:    1.8.0.post1
        - lightning-utilities: 0.3.0
        - linear-operator:   0.1.1
        - llvmlite:          0.39.1
        - lmdb:              1.3.0
        - locket:            1.0.0
        - markdown:          3.4.1
        - markdown-it-py:    2.1.0
        - markupsafe:        2.1.1
        - matplotlib:        3.6.1
        - matplotlib-inline: 0.1.6
        - mccabe:            0.6.1
        - mdit-py-plugins:   0.3.1
        - mdurl:             0.1.2
        - mistune:           2.0.4
        - mock:              4.0.3
        - mosaicml:          0.11.0
        - msgpack:           1.0.4
        - multidict:         6.0.2
        - murmurhash:        1.0.6
        - nbclassic:         0.4.5
        - nbclient:          0.7.0
        - nbconvert:         7.2.1
        - nbformat:          5.7.0
        - nest-asyncio:      1.5.6
        - networkx:          2.6.3
        - ninja:             1.10.2.4
        - nltk:              3.7
        - nodeenv:           1.7.0
        - notebook:          6.4.10
        - notebook-shim:     0.1.0
        - numba:             0.56.2
        - numpy:             1.22.2
        - nvidia-dali-cuda110: 1.18.0
        - nvidia-pyindex:    1.0.9
        - nvtx:              0.2.5
        - oauthlib:          3.2.1
        - omegaconf:         2.2.3
        - onnx:              1.12.0
        - packaging:         21.3
        - pandas:            1.4.4
        - pandocfilters:     1.5.0
        - parso:             0.8.3
        - partd:             1.3.0
        - pathy:             0.6.2
        - pexpect:           4.8.0
        - pickleshare:       0.7.5
        - pillow:            9.0.1
        - pip:               22.3
        - pkginfo:           1.8.3
        - pkgutil-resolve-name: 1.3.10
        - platformdirs:      2.5.2
        - plotly:            5.11.0
        - pluggy:            1.0.0
        - polygraphy:        0.42.1
        - pooch:             1.6.0
        - portalocker:       2.5.1
        - pre-commit:        2.20.0
        - preshed:           3.0.6
        - prettytable:       3.4.1
        - prometheus-client: 0.15.0
        - prompt-toolkit:    3.0.31
        - protobuf:          3.19.6
        - psutil:            5.9.2
        - ptyprocess:        0.7.0
        - pure-eval:         0.2.2
        - py:                1.11.0
        - py-cpuinfo:        8.0.0
        - pyarrow:           8.0.0
        - pyasn1:            0.4.8
        - pyasn1-modules:    0.2.8
        - pybind11:          2.10.0
        - pycocotools:       2.0+nv0.6.0
        - pycodestyle:       2.5.0
        - pycosat:           0.6.3
        - pycparser:         2.21
        - pydantic:          1.8.2
        - pydeprecate:       0.3.2
        - pydot:             1.4.2
        - pyflakes:          2.1.1
        - pygments:          2.13.0
        - pyheck:            0.1.5
        - pylibcugraph:      22.8.0a0+132.g2daa31b6.dirty
        - pynvml:            11.4.1
        - pyopenssl:         22.0.0
        - pyparsing:         3.0.9
        - pyrsistent:        0.18.1
        - pysocks:           1.7.1
        - pytest:            7.2.0
        - pytest-benchmark:  4.0.0
        - pytest-cov:        4.0.0
        - pytest-pythonpath: 0.7.4
        - python-dateutil:   2.8.2
        - python-hostlist:   1.22
        - python-nvd3:       0.15.0
        - python-slugify:    6.1.2
        - pytorch-lightning: 1.7.7
        - pytorch-quantization: 2.1.2
        - pytorch-ranger:    0.1.1
        - pytz:              2022.4
        - pyyaml:            6.0
        - pyzmq:             24.0.1
        - raft:              22.8.0a0+70.g9070c30.dirty
        - regex:             2022.9.13
        - requests:          2.28.1
        - requests-oauthlib: 1.3.1
        - resampy:           0.4.2
        - revtok:            0.0.3
        - rich:              12.6.0
        - rmm:               22.8.0a0+62.gf6bf047.dirty
        - rsa:               4.9
        - ruamel-yaml-conda: 0.15.80
        - ruamel.yaml:       0.17.21
        - ruamel.yaml.clib:  0.2.7
        - sacremoses:        0.0.53
        - scikit-learn:      0.24.2
        - scipy:             1.6.3
        - send2trash:        1.8.0
        - setuptools:        59.5.0
        - shellingham:       1.5.0
        - six:               1.16.0
        - smart-open:        5.2.1
        - sniffio:           1.3.0
        - snowballstemmer:   2.2.0
        - sortedcontainers:  2.4.0
        - soundfile:         0.11.0
        - soupsieve:         2.3.2.post1
        - spacy:             3.2.2
        - spacy-legacy:      3.0.10
        - spacy-loggers:     1.0.3
        - sphinx:            5.2.3
        - sphinx-glpi-theme: 0.3
        - sphinx-rtd-theme:  1.0.0
        - sphinxcontrib-applehelp: 1.0.2
        - sphinxcontrib-devhelp: 1.0.2
        - sphinxcontrib-htmlhelp: 2.0.0
        - sphinxcontrib-jsmath: 1.0.1
        - sphinxcontrib-qthelp: 1.0.3
        - sphinxcontrib-serializinghtml: 1.1.5
        - srsly:             2.4.2
        - stack-data:        0.5.1
        - structlog:         22.1.0
        - tabulate:          0.9.0
        - tblib:             1.7.0
        - tenacity:          8.1.0
        - tensorboard:       2.10.1
        - tensorboard-data-server: 0.6.1
        - tensorboard-plugin-wit: 1.8.1
        - tensorrt:          8.5.0.12
        - termcolor:         2.1.0
        - terminado:         0.16.0
        - text-unidecode:    1.3
        - textual:           0.1.18
        - thinc:             8.0.13
        - threadpoolctl:     3.1.0
        - tinycss2:          1.1.1
        - toml:              0.10.2
        - tomli:             2.0.1
        - toolz:             0.12.0
        - torch:             1.13.0a0+d0d6b1f
        - torch-optimizer:   0.3.0
        - torch-tb-profiler: 0.4.0
        - torch-tensorrt:    1.3.0a0
        - torchmetrics:      0.9.3
        - torchtext:         0.11.0a0
        - torchvision:       0.14.0a0
        - tornado:           6.1
        - tqdm:              4.64.1
        - traitlets:         5.4.0
        - transformer-engine: 0.1.0
        - treelite:          2.4.0
        - treelite-runtime:  2.4.0
        - typeguard:         2.13.3
        - typer:             0.4.2
        - typing-extensions: 4.4.0
        - ucx-py:            0.27.0a0+29.ge9e81f8
        - uff:               0.6.9
        - urllib3:           1.26.11
        - virtualenv:        20.16.6
        - wasabi:            0.10.0
        - wcwidth:           0.2.5
        - webdataset:        0.2.26
        - webencodings:      0.5.1
        - websocket-client:  1.4.1
        - werkzeug:          2.2.2
        - wheel:             0.37.1
        - xgboost:           1.6.1
        - yahp:              0.1.3
        - yarl:              1.8.1
        - zict:              2.2.0
        - zipp:              3.9.0
* System:
        - OS:                Linux
        - architecture:
                - 64bit
                - ELF
        - processor:         x86_64
        - python:            3.8.13
        - version:           #1 SMP Tue Jun 28 15:37:28 UTC 2022

More info

No response

@Pedrexus Pedrexus added the needs triage Waiting to be triaged by maintainers label Nov 3, 2022
@awaelchli
Copy link
Contributor

awaelchli commented Nov 3, 2022

This seems to be a pl_bolts compatibility issue. Bolts is working on adding support for 1.8 here.
This should be fixed in the next release of bolts.

@rohitgr7 @otaj for confirmation :) <3

@awaelchli awaelchli added bug Something isn't working and removed needs triage Waiting to be triaged by maintainers labels Nov 3, 2022
@rohitgr7
Copy link
Contributor

rohitgr7 commented Nov 3, 2022

bolts new version is released... This won't come up now :)

@awaelchli
Copy link
Contributor

The imports have been updated: https://github.com/Lightning-AI/lightning-bolts/blob/master/pl_bolts/utils/__init__.py

🎉

@Rumeysakeskin
Copy link

Rumeysakeskin commented Jan 19, 2023

I faced the same issue as follows,

ImportError: cannot import name '_convert_params' from 'pytorch_lightning.utilities.logger' (/usr/local/lib/python3.8/dist-packages/pytorch_lightning/utilities/logger.py)

Installation of the following commands worked for me:

!apt-get update && apt-get install -y libsndfile1 ffmpeg
!pip install Cython tensorflow==2.11.0 Pygments==2.6.1 pynini==2.1.5 nemo_toolkit[all]

@cnzakimuena
Copy link

cnzakimuena commented Feb 10, 2024

I encountered the same error message,

ImportError: cannot import name '_module_available' from 'pytorch_lightning.utilities'

The following installation fixed the issue for me,

pip install lightning-bolts==0.6.0.post1

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