Skip to content

Commit

Permalink
part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Aug 23, 2024
1 parent 8989686 commit 7644fef
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 202 deletions.
69 changes: 6 additions & 63 deletions notebooks/language-quantize-bert/language-quantize-bert.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file, device_widget"
]
},
{
Expand Down Expand Up @@ -558,14 +558,7 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down Expand Up @@ -770,73 +763,23 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"id": "f71b38a8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Step 1/11] Parsing and validating input arguments\n",
"[ INFO ] Parsing input parameters\n",
"[Step 2/11] Loading OpenVINO Runtime\n",
"[ WARNING ] Default duration 120 seconds is used for unknown device device.value\n",
"[ INFO ] OpenVINO:\n",
"[ INFO ] Build ................................. 2023.0.0-10926-b4452d56304-releases/2023/0\n",
"[ INFO ] \n",
"[ INFO ] Device info:\n",
"[ ERROR ] Check 'false' failed at src/inference/src/core.cpp:84:\n",
"Device with \"device\" name is not registered in the OpenVINO Runtime\n",
"Traceback (most recent call last):\n",
" File \"/home/ea/work/notebooks_convert/notebooks_conv_env/lib/python3.8/site-packages/openvino/tools/benchmark/main.py\", line 103, in main\n",
" benchmark.print_version_info()\n",
" File \"/home/ea/work/notebooks_convert/notebooks_conv_env/lib/python3.8/site-packages/openvino/tools/benchmark/benchmark.py\", line 48, in print_version_info\n",
" for device, version in self.core.get_versions(self.device).items():\n",
"RuntimeError: Check 'false' failed at src/inference/src/core.cpp:84:\n",
"Device with \"device\" name is not registered in the OpenVINO Runtime\n",
"\n"
]
}
],
"outputs": [],
"source": [
"# Inference FP32 model (OpenVINO IR)\n",
"!benchmark_app -m $ir_model_xml -shape [1,128],[1,128],[1,128] -d {device.value} -api sync"
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": null,
"id": "fdf41525",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[Step 1/11] Parsing and validating input arguments\n",
"[ INFO ] Parsing input parameters\n",
"[Step 2/11] Loading OpenVINO Runtime\n",
"[ WARNING ] Default duration 120 seconds is used for unknown device device.value\n",
"[ INFO ] OpenVINO:\n",
"[ INFO ] Build ................................. 2023.0.0-10926-b4452d56304-releases/2023/0\n",
"[ INFO ] \n",
"[ INFO ] Device info:\n",
"[ ERROR ] Check 'false' failed at src/inference/src/core.cpp:84:\n",
"Device with \"device\" name is not registered in the OpenVINO Runtime\n",
"Traceback (most recent call last):\n",
" File \"/home/ea/work/notebooks_convert/notebooks_conv_env/lib/python3.8/site-packages/openvino/tools/benchmark/main.py\", line 103, in main\n",
" benchmark.print_version_info()\n",
" File \"/home/ea/work/notebooks_convert/notebooks_conv_env/lib/python3.8/site-packages/openvino/tools/benchmark/benchmark.py\", line 48, in print_version_info\n",
" for device, version in self.core.get_versions(self.device).items():\n",
"RuntimeError: Check 'false' failed at src/inference/src/core.cpp:84:\n",
"Device with \"device\" name is not registered in the OpenVINO Runtime\n",
"\n"
]
}
],
"outputs": [],
"source": [
"# Inference INT8 model (OpenVINO IR)\n",
"! benchmark_app -m $compressed_model_xml -shape [1,128],[1,128],[1,128] -d {device.value} -api sync"
Expand Down
13 changes: 2 additions & 11 deletions notebooks/llm-question-answering/llm-question-answering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"if not Path(\"./config.py\").exists():\n",
" download_file(url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/notebooks/llm-question-answering/config.py\")\n",
Expand Down Expand Up @@ -470,16 +470,7 @@
"source": [
"core = ov.Core()\n",
"\n",
"support_devices = core.available_devices\n",
"if \"NPU\" in support_devices:\n",
" support_devices.remove(\"NPU\")\n",
"\n",
"device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget(\"CPU\", exclude=[\"NPU\"])\n",
"\n",
"device"
]
Expand Down
39 changes: 10 additions & 29 deletions notebooks/llm-rag-langchain/llm-rag-langchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@
" f.write(r.text)\n",
"\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"with open(\"notebook_utils.py\", \"w\") as f:\n",
" f.write(r.text)\n",
"import notebook_utils as utils\n",
"\n",
"if not text_example_en_path.exists():\n",
" r = requests.get(url=text_example_en)\n",
" content = io.BytesIO(r.content)\n",
Expand Down Expand Up @@ -863,16 +870,7 @@
}
],
"source": [
"core = ov.Core()\n",
"\n",
"support_devices = core.available_devices\n",
"\n",
"embedding_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"embedding_device = utils.device_widget()\n",
"\n",
"embedding_device"
]
Expand Down Expand Up @@ -916,13 +914,6 @@
"npu_embedding_dir = embedding_model_id.value + \"-npu\"\n",
"npu_embedding_path = Path(npu_embedding_dir) / \"openvino_model.xml\"\n",
"if USING_NPU and not Path(npu_embedding_dir).exists():\n",
" r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
" )\n",
" with open(\"notebook_utils.py\", \"w\") as f:\n",
" f.write(r.text)\n",
" import notebook_utils as utils\n",
"\n",
" shutil.copytree(embedding_model_id.value, npu_embedding_dir)\n",
" utils.optimize_bge_embedding(Path(embedding_model_id.value) / \"openvino_model.xml\", npu_embedding_path)"
]
Expand Down Expand Up @@ -961,12 +952,7 @@
}
],
"source": [
"rerank_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"rerank_device = utils.device_widget()\n",
"\n",
"rerank_device"
]
Expand Down Expand Up @@ -1023,12 +1009,7 @@
}
],
"source": [
"llm_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"llm_device = utils.device_widget(\"CPU\", exclude=[\"NPU\"])\n",
"\n",
"llm_device"
]
Expand Down
43 changes: 13 additions & 30 deletions notebooks/llm-rag-llamaindex/llm-rag-llamaindex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@
" f.write(r.text)\n",
"\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"with open(\"notebook_utils.py\", \"w\") as f:\n",
" f.write(r.text)\n",
"import notebook_utils as utils\n",
"\n",
"\n",
"if not text_example_en_path.exists():\n",
" r = requests.get(url=text_example_en)\n",
" content = io.BytesIO(r.content)\n",
Expand Down Expand Up @@ -868,16 +876,7 @@
}
],
"source": [
"core = ov.Core()\n",
"\n",
"support_devices = core.available_devices\n",
"\n",
"embedding_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"embedding_device = utils.device_widget()\n",
"\n",
"embedding_device"
]
Expand All @@ -901,6 +900,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "b552a431",
"metadata": {},
Expand All @@ -919,14 +919,8 @@
"\n",
"npu_embedding_dir = embedding_model_id.value + \"-npu\"\n",
"npu_embedding_path = Path(npu_embedding_dir) / \"openvino_model.xml\"\n",
"if USING_NPU and not Path(npu_embedding_dir).exists():\n",
" r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
" )\n",
" with open(\"notebook_utils.py\", \"w\") as f:\n",
" f.write(r.text)\n",
" import notebook_utils as utils\n",
"\n",
"if USING_NPU and not Path(npu_embedding_dir).exists():\n",
" shutil.copytree(embedding_model_id.value, npu_embedding_dir)\n",
" utils.optimize_bge_embedding(Path(embedding_model_id.value) / \"openvino_model.xml\", npu_embedding_path)"
]
Expand Down Expand Up @@ -965,12 +959,7 @@
}
],
"source": [
"rerank_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"rerank_device = utils.device_widget()\n",
"\n",
"rerank_device"
]
Expand Down Expand Up @@ -1027,13 +1016,7 @@
}
],
"source": [
"llm_device = widgets.Dropdown(\n",
" options=support_devices + [\"AUTO\"],\n",
" value=\"CPU\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"\n",
"llm_device = utils.device_widget(\"CPU\", exclude=[\"NPU\"])\n",
"llm_device"
]
},
Expand Down
11 changes: 2 additions & 9 deletions notebooks/meter-reader/meter-reader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file, segmentation_map_to_image"
"from notebook_utils import download_file, segmentation_map_to_image, device_widget"
]
},
{
Expand Down Expand Up @@ -627,14 +627,7 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
2 changes: 1 addition & 1 deletion notebooks/minicpm-v-multimodal-chatbot/minicpm_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def _adjust_pos_cache(self, tgt_sizes):
max_w = torch.max(tgt_sizes[:, 1])
if max_h > self.max_size[0] or max_w > self.max_size[1]:
self.max_size = [max(max_h, self.max_size[0]), max(max_w, self.max_size[1])]
self._set_2d_pos_cache(self.max_sizes)
self._set_2d_pos_cache(self.max_size)

def get_vllm_embedding(self, data):
if "vision_hidden_states" not in data:
Expand Down
11 changes: 2 additions & 9 deletions notebooks/mobileclip-video-search/mobileclip-video-search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"from notebook_utils import download_file\n",
"from notebook_utils import download_file, device_widget\n",
"\n",
"model_config = available_models[model_checkpoint.value]"
]
Expand Down Expand Up @@ -653,14 +653,7 @@
"source": [
"core = ov.Core()\n",
"\n",
"import ipywidgets as widgets\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
8 changes: 1 addition & 7 deletions notebooks/object-detection-webcam/object-detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,7 @@
"\n",
"core = ov.Core()\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"\n",
"device = utils.device_widget()\n",
"device"
]
},
Expand Down
11 changes: 2 additions & 9 deletions notebooks/oneformer-segmentation/oneformer-segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
")\n",
"\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"from notebook_utils import download_file"
"from notebook_utils import download_file, device_widget"
]
},
{
Expand Down Expand Up @@ -289,16 +289,9 @@
}
],
"source": [
"import ipywidgets as widgets\n",
"\n",
"core = openvino.Core()\n",
"\n",
"device = widgets.Dropdown(\n",
" options=core.available_devices + [\"AUTO\"],\n",
" value=\"AUTO\",\n",
" description=\"Device:\",\n",
" disabled=False,\n",
")\n",
"device = device_widget()\n",
"\n",
"device"
]
Expand Down
Loading

0 comments on commit 7644fef

Please sign in to comment.