NVIDIA / apex

A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch
BSD 3-Clause "New" or "Revised" License
8.16k stars 1.35k forks source link

ImportError: cannot import name '_library_root_logger' from 'apex' (unknown location) #1803

Open BBALU1660 opened 1 month ago

BBALU1660 commented 1 month ago

Error : Traceback (most recent call last): File "/opt/NeMo/scripts/checkpoint_converters/convert_llama_hf_to_nemo.py", line 312, in convert(args) File "/opt/NeMo/scripts/checkpoint_converters/convert_llama_hf_to_nemo.py", line 288, in convert model = load_state_dict_helper(MegatronGPTModel, nemo_config, trainer, checkpoint['state_dict']) File "/opt/NeMo/nemo/collections/nlp/parts/utils_funcs.py", line 217, in load_state_dict_helper model = cls(cfg, trainer) File "/opt/NeMo/nemo/collections/nlp/models/language_modeling/megatron_gpt_model.py", line 287, in init super().init(cfg, trainer=trainer, no_lm_init=True) File "/opt/NeMo/nemo/collections/nlp/models/language_modeling/megatron_base_model.py", line 191, in init initialize_model_parallel_for_nemo( File "/opt/NeMo/nemo/collections/nlp/modules/common/megatron/megatron_init.py", line 159, in initialize_model_parallel_for_nemo set_logging_level(apex_transformer_log_level) File "/opt/apex/apex/transformer/log_util.py", line 16, in set_logging_level from apex import _library_root_logger ImportError: cannot import name '_library_root_logger' from 'apex' (unknown location)

command : python /opt/NeMo/scripts/checkpoint_converters/convert_llama_hf_to_nemo.py --input_name_or_path=./llama2-7b-hf/ --output_path=llama2-7b.nemo

Can anyone help me solve this

arktoswb commented 1 month ago

I had the same issue. Reinstalling Apex helped: https://github.com/NVIDIA/NeMo?tab=readme-ov-file#apex

JesusPaz commented 4 weeks ago

Reinstall Apex works for me, thank you @arktoswb