ModuleNotFoundError:导入 Nvidia Nemo 核心包时没有名为“pytorch_lightning.callbacks.base”的模块

问题描述 投票:0回答:1

当我尝试将 Nvidia NeMo 核心包导入我的 Google Colaboratory 笔记本(连接到本地运行时)时,出现此错误: ModuleNotFoundError:没有名为“pytorch_lightning.callbacks.base”的模块

这些是代码:

BRANCH = 'r1.21.0'
!python -m pip install git+https://github.com/NVIDIA/NeMo.git@$BRANCH#egg=nemo_toolkit[all]

# and then

import nemo
import nemo.collections.asr as nemo_asr 

这些是日志:

-----------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[3], line 5
      2 import nemo
      3 # NeMo's ASR collection - this collections contains complete ASR models and
      4 # building blocks (modules) for ASR
----> 5 import nemo.collections.asr as nemo_asr

File ~\NeMo\nemo\collections\asr\__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      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.
---> 15 from nemo.collections.asr import data, losses, models, modules
     16 from nemo.package_info import __version__
     18 # Set collection version equal to NeMo version.

File ~\NeMo\nemo\collections\asr\models\__init__.py:16
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      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.
     15 from nemo.collections.asr.models.asr_model import ASRModel
---> 16 from nemo.collections.asr.models.classification_models import EncDecClassificationModel
     17 from nemo.collections.asr.models.clustering_diarizer import ClusteringDiarizer
     18 from nemo.collections.asr.models.ctc_bpe_models import EncDecCTCModelBPE

File ~\NeMo\nemo\collections\asr\models\classification_models.py:28
     25 from pytorch_lightning import Trainer
     26 from torchmetrics.regression import MeanAbsoluteError, MeanSquaredError
---> 28 from nemo.collections.asr.data import audio_to_label_dataset
     29 from nemo.collections.asr.models.asr_model import ASRModel, ExportableEncDecModel
     30 from nemo.collections.asr.parts.preprocessing.features import WaveformFeaturizer

File ~\NeMo\nemo\collections\asr\data\audio_to_label_dataset.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      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.
---> 15 from nemo.collections.asr.data import audio_to_label
     16 from nemo.collections.asr.data.audio_to_text_dataset import convert_to_config_list, get_chain_dataset
     19 def get_classification_label_dataset(featurizer, config: dict) -> audio_to_label.AudioToClassificationLabelDataset:

File ~\NeMo\nemo\collections\asr\data\audio_to_label.py:22
     19 import torch
     20 import webdataset as wd
---> 22 from nemo.collections.asr.parts.preprocessing.segment import available_formats as valid_sf_formats
     23 from nemo.collections.common.parts.preprocessing import collections
     24 from nemo.core.classes import Dataset, IterableDataset

File ~\NeMo\nemo\collections\asr\parts\preprocessing\__init__.py:16
      1 # Copyright (c) 2021, NVIDIA CORPORATION.  All rights reserved.
      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.
     15 from nemo.collections.asr.parts.preprocessing.feature_loader import ExternalFeatureLoader
---> 16 from nemo.collections.asr.parts.preprocessing.features import (
     17     STFT,
     18     FeaturizerFactory,
     19     FilterbankFeatures,
     20     STFTExactPad,
     21     STFTPatch,
     22     WaveformFeaturizer,
     23 )
     24 from nemo.collections.asr.parts.preprocessing.perturb import (
     25     AudioAugmentor,
     26     AugmentationDataset,
   (...)
     39     register_perturbation,
     40 )
     41 from nemo.collections.asr.parts.preprocessing.segment import AudioSegment

File ~\NeMo\nemo\collections\asr\parts\preprocessing\features.py:47
     44 from torch.autograd import Variable
     45 from torch_stft import STFT
---> 47 from nemo.collections.asr.parts.preprocessing.perturb import AudioAugmentor
     48 from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
     49 from nemo.utils import logging

File ~\NeMo\nemo\collections\asr\parts\preprocessing\perturb.py:50
     47 from torch.utils.data import IterableDataset
     49 from nemo.collections.asr.parts.preprocessing.segment import AudioSegment
---> 50 from nemo.collections.common.parts.preprocessing import collections, parsers
     51 from nemo.utils import logging
     53 # TODO @blisc: Perhaps refactor instead of import guarding

File ~\NeMo\nemo\collections\common\__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      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.
---> 15 import nemo.collections.common.callbacks
     16 from nemo.collections.common import data, losses, parts, tokenizers
     17 from nemo.package_info import __version__

File ~\NeMo\nemo\collections\common\callbacks\__init__.py:15
      1 # Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.
      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.
---> 15 from nemo.collections.common.callbacks.callbacks import LogEpochTimeCallback

File ~\NeMo\nemo\collections\common\callbacks\callbacks.py:17
     14 import time
     16 import numpy as np
---> 17 from pytorch_lightning.callbacks.base import Callback
     18 from pytorch_lightning.utilities import rank_zero_only
     20 # from sacrebleu import corpus_bleu

ModuleNotFoundError: No module named 'pytorch_lightning.callbacks.base'

以前,我已成功将软件包导入到本地计算机中,但最近,我不得不重新安装 Anaconda。所以我认为这可能是由于某些依赖项未安装造成的。不过我已经通过“pip install pytorch_lightning”安装了 pytorch lighting 并且成功了。

对此有何帮助,我是否缺少另一个导入?

import package google-colaboratory nvidia pytorch-lightning
1个回答
0
投票

我有同样的错误。我不知道如何解决这个问题。如果您已解决,请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.