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

Cannot import name 'default_pg_timeout' from 'torch.distributed' #16637

Closed
ayushnoori opened this issue Feb 5, 2023 · 2 comments · Fixed by #16658
Closed

Cannot import name 'default_pg_timeout' from 'torch.distributed' #16637

ayushnoori opened this issue Feb 5, 2023 · 2 comments · Fixed by #16658
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ayushnoori
Copy link

Bug description

Hi there,

I'm attempting to install PyTorch Lightning on an Apple MacBook Pro with M1 Max Chip. I appeared to successfully install Lightning via:

pip install pytorch-lightning  

However, when I try to actually load the package, I receive the following error message (where {USER_NAME} is my user name and {ENV} is the name of my environment):

>>> import pytorch_lightning as pl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/pytorch_lightning/__init__.py", line 34, in <module>
    from lightning_fabric.utilities.seed import seed_everything  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/lightning_fabric/__init__.py", line 23, in <module>
    from lightning_fabric.fabric import Fabric  # noqa: E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/lightning_fabric/fabric.py", line 34, in <module>
    from lightning_fabric.connector import _Connector, _PLUGIN_INPUT, _PRECISION_INPUT
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/lightning_fabric/connector.py", line 45, in <module>
    from lightning_fabric.strategies import (
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/lightning_fabric/strategies/__init__.py", line 17, in <module>
    from lightning_fabric.strategies.fsdp import FSDPStrategy  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/lightning_fabric/strategies/fsdp.py", line 21, in <module>
    from torch.distributed import default_pg_timeout
ImportError: cannot import name 'default_pg_timeout' from 'torch.distributed' (/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/torch/distributed/__init__.py)

Indeed, when I trace back to torch.distributed, the following also throws an error:

>>> from torch.distributed import default_pg_timeout
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'default_pg_timeout' from 'torch.distributed' (/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.11/site-packages/torch/distributed/__init__.py)

There doesn't seem to be much available to shed light on this error or why the import fails. I'd be grateful for any assistance to help resolve. Thanks!

How to reproduce the bug

No response

Error messages and logs

# Error messages and logs here please

Environment

  • CUDA:
    - GPU: None
    - available: False
    - version: None
  • Lightning:
    - lightning-utilities: 0.6.0.post0
    - pytorch-lightning: 1.9.0
    - torch: 1.13.1
    - torch-geometric: 2.2.0
    - torch-scatter: 2.1.0
    - torch-sparse: 0.6.16
    - torchmetrics: 0.11.1
    - torchvision: 0.2.2
  • Packages:
    - aiohttp: 3.8.3
    - aiosignal: 1.3.1
    - anyio: 3.6.2
    - appnope: 0.1.3
    - argon2-cffi: 21.3.0
    - argon2-cffi-bindings: 21.2.0
    - asttokens: 2.2.1
    - async-timeout: 4.0.2
    - attrs: 22.2.0
    - babel: 2.11.0
    - backcall: 0.2.0
    - backports.functools-lru-cache: 1.6.4
    - beautifulsoup4: 4.11.2
    - bleach: 6.0.0
    - brotlipy: 0.7.0
    - certifi: 2022.12.7
    - cffi: 1.15.1
    - charset-normalizer: 2.1.1
    - comm: 0.1.2
    - cryptography: 39.0.0
    - debugpy: 1.6.6
    - decorator: 5.1.1
    - defusedxml: 0.7.1
    - entrypoints: 0.4
    - executing: 1.2.0
    - fastjsonschema: 2.16.2
    - flit-core: 3.8.0
    - frozenlist: 1.3.3
    - fsspec: 2023.1.0
    - idna: 3.4
    - importlib-metadata: 6.0.0
    - importlib-resources: 5.10.2
    - ipykernel: 6.21.1
    - ipython: 8.9.0
    - ipython-genutils: 0.2.0
    - ipywidgets: 8.0.4
    - jedi: 0.18.2
    - jinja2: 3.1.2
    - joblib: 1.2.0
    - json5: 0.9.5
    - jsonschema: 4.17.3
    - jupyter: 1.0.0
    - jupyter-client: 8.0.2
    - jupyter-console: 6.4.4
    - jupyter-core: 5.2.0
    - jupyter-events: 0.6.3
    - jupyter-server: 2.2.1
    - jupyter-server-terminals: 0.4.4
    - jupyterlab: 3.5.3
    - jupyterlab-pygments: 0.2.2
    - jupyterlab-server: 2.19.0
    - jupyterlab-widgets: 3.0.5
    - lightning-utilities: 0.6.0.post0
    - markupsafe: 2.1.2
    - matplotlib-inline: 0.1.6
    - mistune: 2.0.4
    - multidict: 6.0.4
    - nbclassic: 0.5.1
    - nbclient: 0.7.2
    - nbconvert: 7.2.9
    - nbformat: 5.7.3
    - nest-asyncio: 1.5.6
    - notebook: 6.5.2
    - notebook-shim: 0.2.2
    - numpy: 1.24.1
    - packaging: 23.0
    - pandocfilters: 1.5.0
    - parso: 0.8.3
    - pexpect: 4.8.0
    - pickleshare: 0.7.5
    - pillow: 9.4.0
    - pip: 23.0
    - pkgutil-resolve-name: 1.3.10
    - platformdirs: 2.6.2
    - prometheus-client: 0.16.0
    - prompt-toolkit: 3.0.36
    - psutil: 5.9.4
    - ptyprocess: 0.7.0
    - pure-eval: 0.2.2
    - pycparser: 2.21
    - pygments: 2.14.0
    - pyopenssl: 23.0.0
    - pyparsing: 3.0.9
    - pyrsistent: 0.19.3
    - pysocks: 1.7.1
    - python-dateutil: 2.8.2
    - python-json-logger: 2.0.4
    - pytorch-lightning: 1.9.0
    - pytz: 2022.7.1
    - pyyaml: 6.0
    - pyzmq: 25.0.0
    - requests: 2.28.2
    - rfc3339-validator: 0.1.4
    - rfc3986-validator: 0.1.1
    - scikit-learn: 1.2.1
    - scipy: 1.10.0
    - send2trash: 1.8.0
    - setuptools: 67.1.0
    - six: 1.16.0
    - sniffio: 1.3.0
    - soupsieve: 2.3.2.post1
    - stack-data: 0.6.2
    - terminado: 0.17.1
    - threadpoolctl: 3.1.0
    - tinycss2: 1.2.1
    - tomli: 2.0.1
    - torch: 1.13.1
    - torch-geometric: 2.2.0
    - torch-scatter: 2.1.0
    - torch-sparse: 0.6.16
    - torchmetrics: 0.11.1
    - torchvision: 0.2.2
    - tornado: 6.2
    - tqdm: 4.64.1
    - traitlets: 5.9.0
    - typing-extensions: 4.4.0
    - urllib3: 1.26.14
    - wcwidth: 0.2.6
    - webencodings: 0.5.1
    - websocket-client: 1.5.1
    - wheel: 0.38.4
    - widgetsnbextension: 4.0.5
    - yarl: 1.8.2
    - zipp: 3.12.0
  • System:
    - OS: Darwin
    - architecture:
    - 64bit
    -
    - processor: arm
    - python: 3.11.0
    - version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000

More info

No response

@ayushnoori ayushnoori added bug Something isn't working needs triage Waiting to be triaged by maintainers labels Feb 5, 2023
@awaelchli
Copy link
Contributor

Hi @ayushnoori
What does torch.distributed.is_available() return for you?

@awaelchli awaelchli removed the needs triage Waiting to be triaged by maintainers label Feb 6, 2023
@awaelchli awaelchli added this to the v1.9.x milestone Feb 6, 2023
@awaelchli awaelchli self-assigned this Feb 6, 2023
@ayushnoori
Copy link
Author

Thanks for your help, @awaelchli!

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

Successfully merging a pull request may close this issue.

2 participants