NeMo icon indicating copy to clipboard operation
NeMo copied to clipboard

ImportError: cannot import name '_is_local_file_protocol' from 'pytorch_lightning.callbacks.model_checkpoint'

Open eesaeedkarimi opened this issue 1 year ago • 1 comments

When I run from nemo.collections.tts.models.base import SpectrogramGenerator I get this error: Traceback (most recent call last): File "/home/saeed/Codes/NeMo/tutorials/tts/Inference_ModelSelect.py", line 3, in <module> from nemo.collections.tts.models.base import SpectrogramGenerator File "/home/saeed/Codes/NeMo/nemo/collections/tts/__init__.py", line 15, in <module> from nemo.collections.tts import data, losses, models, modules File "/home/saeed/Codes/NeMo/nemo/collections/tts/models/__init__.py", line 16, in <module> from nemo.collections.tts.models.audio_codec import AudioCodecModel File "/home/saeed/Codes/NeMo/nemo/collections/tts/models/audio_codec.py", line 27, in <module> from nemo.collections.tts.losses.audio_codec_loss import ( File "/home/saeed/Codes/NeMo/nemo/collections/tts/losses/audio_codec_loss.py", line 21, in <module> from nemo.collections.asr.parts.preprocessing.features import FilterbankFeatures File "/home/saeed/Codes/NeMo/nemo/collections/asr/__init__.py", line 15, in <module> from nemo.collections.asr import data, losses, models, modules File "/home/saeed/Codes/NeMo/nemo/collections/asr/models/__init__.py", line 15, in <module> from nemo.collections.asr.models.aed_multitask_models import EncDecMultiTaskModel File "/home/saeed/Codes/NeMo/nemo/collections/asr/models/aed_multitask_models.py", line 29, in <module> from nemo.collections.asr.metrics import BLEU, WER File "/home/saeed/Codes/NeMo/nemo/collections/asr/metrics/__init__.py", line 15, in <module> from nemo.collections.asr.metrics.bleu import BLEU File "/home/saeed/Codes/NeMo/nemo/collections/asr/metrics/bleu.py", line 22, in <module> from nemo.collections.asr.parts.submodules.multitask_decoding import AbstractMultiTaskDecoding File "/home/saeed/Codes/NeMo/nemo/collections/asr/parts/submodules/multitask_decoding.py", line 23, in <module> from nemo.collections.asr.parts.submodules.multitask_beam_decoding import ( File "/home/saeed/Codes/NeMo/nemo/collections/asr/parts/submodules/multitask_beam_decoding.py", line 21, in <module> from nemo.collections.asr.modules.transformer import BeamSearchSequenceGenerator File "/home/saeed/Codes/NeMo/nemo/collections/asr/modules/__init__.py", line 15, in <module> from nemo.collections.asr.modules.audio_modules import ( File "/home/saeed/Codes/NeMo/nemo/collections/asr/modules/audio_modules.py", line 21, in <module> from nemo.collections.asr.modules.conformer_encoder import ConformerEncoder File "/home/saeed/Codes/NeMo/nemo/collections/asr/modules/conformer_encoder.py", line 26, in <module> from nemo.collections.asr.models.configs import CacheAwareStreamingConfig File "/home/saeed/Codes/NeMo/nemo/collections/asr/models/configs/__init__.py", line 15, in <module> from nemo.collections.asr.models.configs.asr_models_config import ( File "/home/saeed/Codes/NeMo/nemo/collections/asr/models/configs/asr_models_config.py", line 27, in <module> from nemo.core.config import modelPT as model_cfg File "/home/saeed/Codes/NeMo/nemo/core/config/modelPT.py", line 22, in <module> from nemo.utils import exp_manager File "/home/saeed/Codes/NeMo/nemo/utils/exp_manager.py", line 43, in <module> from nemo.utils.callbacks import NeMoModelCheckpoint, PreemptionCallback File "/home/saeed/Codes/NeMo/nemo/utils/callbacks/__init__.py", line 16, in <module> from nemo.utils.callbacks.nemo_model_checkpoint import NeMoModelCheckpoint File "/home/saeed/Codes/NeMo/nemo/utils/callbacks/nemo_model_checkpoint.py", line 24, in <module> from pytorch_lightning.callbacks.model_checkpoint import ModelCheckpoint, _is_local_file_protocol ImportError: cannot import name '_is_local_file_protocol' from 'pytorch_lightning.callbacks.model_checkpoint'

I also can't find a function or variable named _is_local_file_protocol in the 'pytorch_lightning.callbacks.model_checkpoint'.

Environment overview

I have used a python virtual environment and installed the requirements with these commands: apt-get update && apt-get install -y libsndfile1 ffmpeg pip install Cython pip install nemo_toolkit['tts']

Environment details

My pytorch-lightning version is 1.4.0

eesaeedkarimi avatar Apr 29 '24 07:04 eesaeedkarimi

I had the same issue and updated to pytorch-lightning=2.2.1 and it worked. Somehow, when I installed everything from scratch, using pip install nemo_toolkit['all'], it did not install the right pytorch-lightning. If you look at the requirements files, it says it requires at least 2.2.1:

cat requirements/requirements_lightning.txt
cloudpickle
fiddle
hydra-core>1.3,<=1.3.2
omegaconf<=2.3
pytorch-lightning>=2.2.1
torchmetrics>=0.11.0
transformers>=4.36.0
wandb
webdataset>=0.2.86

migueljette avatar May 03 '24 21:05 migueljette

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 14 '24 01:06 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Jun 22 '24 01:06 github-actions[bot]