Skip to content

Conversation

@Borda
Copy link
Collaborator

@Borda Borda commented Apr 9, 2022

What does this PR do?

there is a potential issue when your torchtext is not build correctly

ImportError                               Traceback (most recent call last)
Input In [2], in <cell line: 8>()
      6 import numpy as np
      7 import torch
----> 8 from pytorch_lightning import LightningModule, Trainer
      9 from pytorch_lightning.utilities import DistributedType
     10 from torch import Tensor, nn

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/__init__.py:30, in <module>
     27     _logger.addHandler(logging.StreamHandler())
     28     _logger.propagate = False
---> 30 from pytorch_lightning.callbacks import Callback  # noqa: E402
     31 from pytorch_lightning.core import LightningDataModule, LightningModule  # noqa: E402
     32 from pytorch_lightning.trainer import Trainer  # noqa: E402

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/callbacks/__init__.py:14, in <module>
      1 # Copyright The PyTorch Lightning team.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
---> 14 from pytorch_lightning.callbacks.base import Callback
     15 from pytorch_lightning.callbacks.device_stats_monitor import DeviceStatsMonitor
     16 from pytorch_lightning.callbacks.early_stopping import EarlyStopping

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/callbacks/base.py:25, in <module>
     22 from torch.optim import Optimizer
     24 import pytorch_lightning as pl
---> 25 from pytorch_lightning.utilities.types import STEP_OUTPUT
     28 class Callback:
     29     r"""
     30     Abstract base class used to build new callbacks.
     31 
     32     Subclass this class and override any of the relevant hooks
     33     """

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/utilities/__init__.py:18, in <module>
     14 """General utilities."""
     16 import numpy
---> 18 from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
     19 from pytorch_lightning.utilities.distributed import AllGatherGrad  # noqa: F401
     20 from pytorch_lightning.utilities.enums import (  # noqa: F401
     21     _AcceleratorType,
     22     _StrategyType,
   (...)
     27     ModelSummaryMode,
     28 )

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/utilities/apply_func.py:29, in <module>
     26 import torch
     28 from pytorch_lightning.utilities.exceptions import MisconfigurationException
---> 29 from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_LEGACY
     30 from pytorch_lightning.utilities.warnings import rank_zero_deprecation
     32 if _TORCHTEXT_LEGACY:

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/utilities/imports.py:116, in <module>
    114 _TORCH_QUANTIZE_AVAILABLE = bool([eg for eg in torch.backends.quantized.supported_engines if eg != "none"])
    115 _TORCHTEXT_AVAILABLE = _package_available("torchtext")
--> 116 _TORCHTEXT_LEGACY: bool = _TORCHTEXT_AVAILABLE and _compare_version("torchtext", operator.lt, "0.11.0")
    117 _TORCHVISION_AVAILABLE = _package_available("torchvision")
    118 _WANDB_AVAILABLE = _package_available("wandb")

File ~/.local/lib/python3.9/site-packages/pytorch_lightning/utilities/imports.py:69, in _compare_version(package, op, version, use_base_version)
     63 """Compare package version with some requirements.
     64 
     65 >>> _compare_version("torch", operator.ge, "0.1")
     66 True
     67 """
     68 try:
---> 69     pkg = importlib.import_module(package)
     70 except (ModuleNotFoundError, DistributionNotFound):
     71     return False

File /usr/lib/python3.9/importlib/__init__.py:127, in import_module(name, package)
    125             break
    126         level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File /usr/local/lib/python3.9/dist-packages/torchtext/__init__.py:5, in <module>
      3 from . import datasets
      4 from . import utils
----> 5 from . import vocab
      6 from . import legacy
      7 from ._extension import _init_extension

File /usr/local/lib/python3.9/dist-packages/torchtext/vocab/__init__.py:11, in <module>
      1 from .vocab import Vocab
      3 from .vectors import (
      4     GloVe,
      5     FastText,
   (...)
      8     Vectors,
      9 )
---> 11 from .vocab_factory import (
     12     vocab,
     13     build_vocab_from_iterator,
     14 )
     16 __all__ = ["Vocab",
     17            "vocab",
     18            "build_vocab_from_iterator",
   (...)
     22            "pretrained_aliases",
     23            "Vectors"]

File /usr/local/lib/python3.9/dist-packages/torchtext/vocab/vocab_factory.py:4, in <module>
      2 from typing import Dict, Iterable, Optional, List
      3 from collections import Counter, OrderedDict
----> 4 from torchtext._torchtext import (
      5     Vocab as VocabPybind,
      6 )
      9 def vocab(ordered_dict: Dict, min_freq: int = 1) -> Vocab:
     10     r"""Factory method for creating a vocab object which maps tokens to indices.
     11 
     12     Note that the ordering in which key value pairs were inserted in the `ordered_dict` will be respected when building the vocab.
   (...)
     42         >>> v2['out of vocab'] is v2[unk_token] #prints True
     43     """

ImportError: /usr/local/lib/python3.9/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZTVN5torch3jit6MethodE

see: https://dev.azure.com/PytorchLightning/Tutorials/_build/results?buildId=66516&view=logs&j=4d809e3c-18a0-5a8d-e0ac-4c5682e3f11b&t=ccd228a0-6bb7-550f-2646-371fba78c5ec

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

cc @Borda @tchaton @rohitgr7

@Borda Borda added priority: 1 Medium priority task bug Something isn't working labels Apr 9, 2022
@Borda Borda added this to the 1.6.x milestone Apr 9, 2022
@Borda Borda enabled auto-merge (squash) April 9, 2022 11:30
@Borda Borda requested a review from a team April 9, 2022 11:41
@Borda Borda self-assigned this Apr 9, 2022
@Borda Borda requested review from a team, kaushikb11 and rohitgr7 April 9, 2022 14:54
@awaelchli awaelchli changed the title fix import failled fix import failed Apr 10, 2022
Co-authored-by: Akihiro Nitta <nitta@akihironitta.com>
Copy link
Contributor

@krshrimali krshrimali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mergify mergify bot added the ready PRs ready to be merged label Apr 11, 2022
@carmocca carmocca modified the milestone: 1.6.x Apr 11, 2022
@Borda Borda merged commit 3686778 into master Apr 11, 2022
@Borda Borda deleted the fix/imports branch April 11, 2022 15:10
rohitgr7 pushed a commit that referenced this pull request Apr 12, 2022
lexierule pushed a commit that referenced this pull request Apr 13, 2022
@rohitgr7 rohitgr7 mentioned this pull request Jul 1, 2022
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: 1 Medium priority task ready PRs ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants