aws-samples / large-model-workshop-financial-services

This code repository contains code assets of "Generative AI Large Language Model Workshop for Financial Services" workshop
https://catalog.us-east-1.prod.workshops.aws/workshops/c8e0f5d8-0658-4345-8b1d-cc637cbdd671
MIT No Attribution
18 stars 6 forks source link

Dependencies issues when running lab3/2_financial_news_summarization/t5_python_backend.ipynb #4

Open AnirudhVIyer opened 6 months ago

AnirudhVIyer commented 6 months ago

When running the notebook on sagemaker. Instance crashes due to the following error:

2024-03-31T11:07:35.292-04:00 ErrorMessage "ImportError: cannot import name 'is_npu_available' from 'accelerate.utils' (/opt/conda/lib/python3.9/site-packages/accelerate/utils/init.py) ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /opt/ml/code/train.py:16 in │ │ │ │ 13 from accelerate.utils import LoggerType │ │ 14 from datasets import concatenate_datasets │ │ 15 from nltk.tokenize import sent_tokenize │ │ ❱ 16 from peft import LoraConfig, TaskType, get_peft_model, get_peftmodel │ │ 17 from torch.utils.data import DataLoader │ │ 18 from tqdm import tqdm │ │ 19 from transformers import ( │ │ /opt/conda/lib/python3.9/site-packages/peft/init.py:22 in │ │ 19 │ │ 20 version = "0.5.0" │ │ 21 │ │ ❱ 22 from .auto import ( │ │ 23 │ AutoPeftModel, │ │ 24 │ AutoPeftModelForCausalLM, │ │ 25 │ AutoPeftModelForSequenceClassification, │ │ /opt/conda/lib/python3.9/site-packages/peft/auto.py:30 in │ │ 27 │ AutoModelForTokenClassification, │ │ 28 ) │ │ 29 │ │ ❱ 30 from .config import PeftConfig │ │ 31 from .mapping import MODEL_TYPE_TO_PEFT_MODEL_MAPPING │ │ 32 from .peft_model import ( │ │ 33 │ PeftModel, │ │ /opt/conda/lib/python3.9/site-packages/peft/config.py:24 in │ │ 21 from huggingface_hub import hf_hub_download │ │ 22 from transformers.utils import PushToHubMixin │ │ 23 │ │ ❱ 24 from .utils import CONFIG_NAME, PeftType, TaskType │ │ 25 │ │ 26 │ │ 27 @dataclass │ │ /opt/conda/lib/python3.9/site-packages/peft/utils/init.py:22 in │ │ 20 # from .config import PeftConfig, PeftType, PromptLearningConfig, TaskT │ │ 21 from .peft_types import PeftType, TaskType │ │ ❱ 22 from .other import ( │ │ 23 │ TRANSFORMERS_MODELS_TO_PREFIX_TUNING_POSTPROCESS_MAPPING, │ │ 24 │ TRANSFORMERS_MODELS_TO_LORA_TARGET_MODULES_MAPPING, │ │ 25 │ TRANSFORMERS_MODELS_TO_ADALORA_TARGET_MODULES_MAPPING, │ │ /opt/conda/lib/python3.9/site-packages/peft/utils/other.py:24 in │ │ 21 import accelerate │ │ 22 import torch │ │ 23 from accelerate.hooks import add_hook_to_module, remove_hook_from_modu │ │ ❱ 24 from accelerate.utils import is_npu_available, is_xpu_available │ │ 26 from ..import_utils import is_auto_gptq_available │ │ 27 │ ╰──────────────────────────────────────────────────────────────────────────────╯ │ /opt/conda/bin/accelerate:8 in │ │ 5 from accelerate.commands.accelerate_cli import main │ │ 6 if name == 'main': │ │ 7 │ sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) │ │ ❱ 8 │ sys.exit(main()) │ │ 9 │ │ /opt/conda/lib/python3.9/site-packages/accelerate/commands/accelerate_cli.py │ │ :45 in main │ │ 42 │ │ exit(1) │ │ 43 │ │ │ 44 │ # Run │ │ ❱ 45 │ args.func(args) │ │ 46 │ │ 47 │ │ 48 if name == "main": │ │ /opt/conda/lib/python3.9/site-packages/accelerate/commands/launch.py:900 in │ │ launch_command │ │ 897 │ │ if mp_from_config_flag: │ │ 898 │ │ │ args.deepspeed_fields_from_accelerate_config.append("mixed │ │ 899 │ │ args.deepspeed_fields_from_accelerate_config = ",".join(args.d │ │ ❱ 900 │ │ deepspeed_launcher(args) │ │ 901 │ elif args.use_fsdp and not args.cpu: │ │ 902 │ │ multi_gpu_launcher(args) │ │ 903 │ elif args.use_megatron_lm and not args.cpu: │ │ /opt/conda/lib/python3.9/site-packages/accelerate/commands/launch.py:643 in │ │ deepspeed_launcher │ │ 640 │ │ ) │ │ 641 │ │ with patch_environment(*current_env): │ │ 642 │ │ │ try: │ │ ❱ 643 │ │ │ │ distrib_run.run(args) │ │ 644 │ │ │ except Exception: │ │ 645 │ │ │ │ if is_rich_available() and debug: │ │ 646 │ │ │ │ │ console = get_console() │ │ /opt/conda/lib/python3.9/site-packages/torch/distributed/run.py:753 in run │ │ 750 │ │ ) │ │ 751 │ │ │ 752 │ config, cmd, cmd_args = config_from_args(args) │ │ ❱ 753 │ elastic_launch( │ │ 754 │ │ config=config, │ │ 755 │ │ entrypoint=cmd, │ │ 756 │ )(cmd_args) │ │ /opt/conda/lib/python3.9/site-packages/torch/distributed/launcher/api.py:132 │ │ in call │ │ 129 │ │ self._entrypoint = entrypoint │ │ 130 │ │ │ 131 │ def call(self, *args): │ │ ❱ 132 │ │ return launch_agent(self._config, self._entrypoint, list(args) │ │ 133 │ │ 134 │ │ 135 def _get_entrypoint_name( │ │ /opt/conda/lib/python3.9/site-packages/torch/distributed/launcher/api.py:246 │ │ in launch_agent │ │ 243 │ │ │ # if the error files for the failed children exist │ │ 244 │ │ │ # @record will copy the first error (root cause) │ │ 245 │ │ │ # to the error file of the launcher process. │ │ ❱ 246 │ │ │ raise ChildFailedError( │ │ 247 │ │ │ │ name=entrypoint_name, │ │ 248 │ │ │ │ failures=result.failures, │ │ 249 │ │ │ ) │

From what I can understand this error is due to installing the peft package. It causes dependency issues. I need to use Peft with Deepspeed for Finetuning a LLM. Any suggestions?