From b15d434f152fad2afed24da86c3891f9a096e731 Mon Sep 17 00:00:00 2001 From: Aleksandr Mokrov Date: Thu, 16 Jan 2025 15:01:27 +0100 Subject: [PATCH] Update transformers to fix CalledProcessError in optimum-cli call (#2657) CVS-156213 --- .../text-to-image-genai.ipynb | 1 + .../whisper-asr-genai/whisper-asr-genai.ipynb | 19 ++++++++++--------- .../whisper-subtitles-generation.ipynb | 18 +++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/notebooks/text-to-image-genai/text-to-image-genai.ipynb b/notebooks/text-to-image-genai/text-to-image-genai.ipynb index d4f51ecaf6f..d37df1eb46e 100644 --- a/notebooks/text-to-image-genai/text-to-image-genai.ipynb +++ b/notebooks/text-to-image-genai/text-to-image-genai.ipynb @@ -60,6 +60,7 @@ "\n", "%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\"\n", "%pip install -q -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly \"openvino>=2024.5\" \"openvino-tokenizers>=2024.5\" \"openvino-genai>=2024.5\"\n", + "%pip install -q -U \"transformers>=4.45\" --extra-index-url https://download.pytorch.org/whl/cpu\n", "%pip install -q Pillow \"diffusers>=0.30.3\" \"gradio>=4.19\" \"typing_extensions>=4.9\" \"tqdm\"\n", "if platform.system() == \"Darwin\":\n", " %pip install -q \"numpy<2.0.0\"\n", diff --git a/notebooks/whisper-asr-genai/whisper-asr-genai.ipynb b/notebooks/whisper-asr-genai/whisper-asr-genai.ipynb index 7c9df7d324f..b4ad9f06e58 100644 --- a/notebooks/whisper-asr-genai/whisper-asr-genai.ipynb +++ b/notebooks/whisper-asr-genai/whisper-asr-genai.ipynb @@ -75,8 +75,9 @@ "\n", "\n", "%pip install -q \"torch>=2.3\" \"torchvision>=0.18.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n", - "%pip install -q \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" --extra-index-url https://download.pytorch.org/whl/cpu\n", - "%pip install -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n", + "%pip install -q -U \"transformers>=4.45\" --extra-index-url https://download.pytorch.org/whl/cpu\n", + "%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\" --extra-index-url https://download.pytorch.org/whl/cpu\n", + "%pip install --pre -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n", "%pip install -q datasets \"gradio>=4.0\" \"soundfile>=0.12\" \"librosa\" \"python-ffmpeg<=1.0.16\"\n", "%pip install -q \"nncf>=2.14.0\" \"jiwer\" \"typing_extensions>=4.9\"\n", "if platform.system() == \"Darwin\":\n", @@ -995,7 +996,7 @@ " encoder_calibration_data = []\n", " decoder_calibration_data = []\n", " ov_model.encoder.request = InferRequestWrapper(ov_model.encoder.request, encoder_calibration_data, apply_caching=True)\n", - " ov_model.decoder_with_past.request = InferRequestWrapper(ov_model.decoder_with_past.request,\n", + " ov_model.decoder.request = InferRequestWrapper(ov_model.decoder.request,\n", " decoder_calibration_data,\n", " apply_caching=True)\n", "\n", @@ -1012,7 +1013,7 @@ " pipe(sample[\"audio\"], return_timestamps=True)\n", " finally:\n", " ov_model.encoder.request = ov_model.encoder.request.request\n", - " ov_model.decoder_with_past.request = ov_model.decoder_with_past.request.request\n", + " ov_model.decoder.request = ov_model.decoder.request.request\n", "\n", " return encoder_calibration_data, decoder_calibration_data" ] @@ -1070,17 +1071,17 @@ " del encoder_calibration_data\n", " gc.collect()\n", "\n", - " print(\"Quantizing decoder with past\")\n", - " quantized_decoder_with_past = nncf.quantize(\n", - " ov_model.decoder_with_past.model,\n", + " print(\"Quantizing decoder\")\n", + " quantized_decoder = nncf.quantize(\n", + " ov_model.decoder.model,\n", " nncf.Dataset(decoder_calibration_data),\n", " subset_size=len(decoder_calibration_data),\n", " model_type=nncf.ModelType.TRANSFORMER,\n", " # Smooth Quant algorithm reduces activation quantization error; optimal alpha value was obtained through grid search\n", " advanced_parameters=nncf.AdvancedQuantizationParameters(smooth_quant_alpha=0.96)\n", " )\n", - " ov.save_model(quantized_decoder_with_past, quantized_model_path / \"openvino_decoder_with_past_model.xml\")\n", - " del quantized_decoder_with_past\n", + " ov.save_model(quantized_decoder, quantized_model_path / \"openvino_decoder_model.xml\")\n", + " del quantized_decoder\n", " del decoder_calibration_data\n", " gc.collect()\n", "\n", diff --git a/notebooks/whisper-subtitles-generation/whisper-subtitles-generation.ipynb b/notebooks/whisper-subtitles-generation/whisper-subtitles-generation.ipynb index c82ea3028e8..36f74d416fa 100644 --- a/notebooks/whisper-subtitles-generation/whisper-subtitles-generation.ipynb +++ b/notebooks/whisper-subtitles-generation/whisper-subtitles-generation.ipynb @@ -87,8 +87,8 @@ "import importlib.util\n", "\n", "%pip install -q \"nncf>=2.14.0\"\n", - "%pip install -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n", - "%pip install -q \"python-ffmpeg<=1.0.16\" \"ffmpeg\" \"moviepy\" \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" \"torch>=2.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n", + "%pip install --pre -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n", + "%pip install -q -U \"python-ffmpeg<=1.0.16\" \"ffmpeg\" \"moviepy\" \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" \"torch>=2.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n", "%pip install -q -U \"yt_dlp>=2024.8.6\" soundfile librosa jiwer packaging\n", "%pip install -q -U \"gradio>=4.19\" \"typing_extensions>=4.9\"\n", "\n", @@ -744,7 +744,7 @@ " encoder_calibration_data = []\n", " decoder_calibration_data = []\n", " ov_model.encoder.request = InferRequestWrapper(ov_model.encoder.request, encoder_calibration_data, apply_caching=True)\n", - " ov_model.decoder_with_past.request = InferRequestWrapper(ov_model.decoder_with_past.request,\n", + " ov_model.decoder.request = InferRequestWrapper(ov_model.decoder.request,\n", " decoder_calibration_data,\n", " apply_caching=True)\n", "\n", @@ -761,7 +761,7 @@ " pipe(sample[\"audio\"], generate_kwargs={\"task\": task.value}, return_timestamps=True)\n", " finally:\n", " ov_model.encoder.request = ov_model.encoder.request.request\n", - " ov_model.decoder_with_past.request = ov_model.decoder_with_past.request.request\n", + " ov_model.decoder.request = ov_model.decoder.request.request\n", "\n", " return encoder_calibration_data, decoder_calibration_data" ] @@ -812,17 +812,17 @@ " del encoder_calibration_data\n", " gc.collect()\n", "\n", - " print(\"Quantizing decoder with past\")\n", - " quantized_decoder_with_past = nncf.quantize(\n", - " ov_model.decoder_with_past.model,\n", + " print(\"Quantizing decoder\")\n", + " quantized_decoder = nncf.quantize(\n", + " ov_model.decoder.model,\n", " nncf.Dataset(decoder_calibration_data),\n", " subset_size=len(decoder_calibration_data),\n", " model_type=nncf.ModelType.TRANSFORMER,\n", " # Smooth Quant algorithm reduces activation quantization error; optimal alpha value was obtained through grid search\n", " advanced_parameters=nncf.AdvancedQuantizationParameters(smooth_quant_alpha=0.96),\n", " )\n", - " ov.save_model(quantized_decoder_with_past, quantized_model_path / \"openvino_decoder_with_past_model.xml\")\n", - " del quantized_decoder_with_past\n", + " ov.save_model(quantized_decoder, quantized_model_path / \"openvino_decoder_model.xml\")\n", + " del quantized_decoder\n", " del decoder_calibration_data\n", " gc.collect()\n", "\n",