Skip to content

Commit 86b32be

Browse files
authored
apply gpu configuration for yolo8 according recomendation (openvinotoolkit#1779)
1 parent e5830a1 commit 86b32be

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

notebooks/122-quantizing-model-with-accuracy-control/122-yolov8-quantization-with-accuracy-control.ipynb

+5-2
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,11 @@
641641
],
642642
"source": [
643643
"core = ov.Core()\n",
644-
"quantized_compiled_model = core.compile_model(model=quantized_model, device_name=device.value)\n",
645-
"compiled_ov_model = core.compile_model(model=ov_model, device_name=device.value)\n",
644+
"ov_config = {}\n",
645+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
646+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
647+
"quantized_compiled_model = core.compile_model(model=quantized_model, device_name=device.value, ov_config)\n",
648+
"compiled_ov_model = core.compile_model(model=ov_model, device_name=device.value, ov_config)\n",
646649
"\n",
647650
"pt_result = validation_ac(compiled_ov_model, data_loader, validator)\n",
648651
"quantized_result = validation_ac(quantized_compiled_model, data_loader, validator)\n",

notebooks/230-yolov8-optimization/230-yolov8-instance-segmentation.ipynb

+9-3
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,10 @@
645645
"seg_ov_model = core.read_model(seg_model_path)\n",
646646
"if device.value != \"CPU\":\n",
647647
" seg_ov_model.reshape({0: [1, 3, 640, 640]})\n",
648-
"seg_compiled_model = core.compile_model(seg_ov_model, device.value)\n",
648+
"ov_config = {}\n",
649+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
650+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
651+
"seg_compiled_model = core.compile_model(seg_ov_model, device.value, ov_config)\n",
649652
"\n",
650653
"\n",
651654
"def detect(image:np.ndarray, model:ov.Model):\n",
@@ -1185,7 +1188,7 @@
11851188
"source": [
11861189
"if device.value != \"CPU\":\n",
11871190
" quantized_seg_model.reshape({0: [1, 3, 640, 640]})\n",
1188-
"quantized_seg_compiled_model = core.compile_model(quantized_seg_model, device.value)\n",
1191+
"quantized_seg_compiled_model = core.compile_model(quantized_seg_model, device.value, ov_config)\n",
11891192
"input_image = np.array(Image.open(IMAGE_PATH))\n",
11901193
"detections = detect(input_image, quantized_seg_compiled_model)[0]\n",
11911194
"image_with_masks = draw_results(detections, input_image, label_map)\n",
@@ -1548,7 +1551,10 @@
15481551
" player = None\n",
15491552
" if device != \"CPU\":\n",
15501553
" model.reshape({0: [1, 3, 640, 640]})\n",
1551-
" compiled_model = core.compile_model(model, device)\n",
1554+
" ov_config = {}\n",
1555+
" if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
1556+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
1557+
" compiled_model = core.compile_model(model, device, ov_config)\n",
15521558
" try:\n",
15531559
" # Create a video player to play with target fps.\n",
15541560
" player = VideoPlayer(\n",

notebooks/230-yolov8-optimization/230-yolov8-keypoint-detection.ipynb

+12-3
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,10 @@
634634
"pose_ov_model = core.read_model(pose_model_path)\n",
635635
"if device.value != \"CPU\":\n",
636636
" pose_ov_model.reshape({0: [1, 3, 640, 640]})\n",
637-
"pose_compiled_model = core.compile_model(pose_ov_model, device.value)\n",
637+
"ov_config = {}\n",
638+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
639+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
640+
"pose_compiled_model = core.compile_model(pose_ov_model, device.value, ov_config)\n",
638641
"\n",
639642
"\n",
640643
"def detect(image:np.ndarray, model:ov.Model):\n",
@@ -1188,7 +1191,10 @@
11881191
"source": [
11891192
"if device.value != \"CPU\":\n",
11901193
" quantized_pose_model.reshape({0: [1, 3, 640, 640]})\n",
1191-
"quantized_pose_compiled_model = core.compile_model(quantized_pose_model, device.value)\n",
1194+
"ov_config = {}\n",
1195+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
1196+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
1197+
"quantized_pose_compiled_model = core.compile_model(quantized_pose_model, device.value, ov_config)\n",
11921198
"input_image = np.array(Image.open(IMAGE_PATH))\n",
11931199
"detections = detect(input_image, quantized_pose_compiled_model)[0]\n",
11941200
"image_with_boxes = draw_results(detections, input_image, label_map)\n",
@@ -1546,7 +1552,10 @@
15461552
" player = None\n",
15471553
" if device != \"CPU\":\n",
15481554
" model.reshape({0: [1, 3, 640, 640]})\n",
1549-
" compiled_model = core.compile_model(model, device)\n",
1555+
" ov_config = {}\n",
1556+
" if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
1557+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
1558+
" compiled_model = core.compile_model(model, device, ov_config)\n",
15501559
" try:\n",
15511560
" # Create a video player to play with target fps.\n",
15521561
" player = VideoPlayer(\n",

notebooks/230-yolov8-optimization/230-yolov8-object-detection.ipynb

+15-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"\n",
2828
"\n",
2929
"\n",
30-
"#### Table of contents:\n\n",
30+
"#### Table of contents:\n",
31+
"\n",
3132
"- [Get PyTorch model](#Get-PyTorch-model)\n",
3233
" - [Prerequisites](#Prerequisites)\n",
3334
"- [Instantiate model](#Instantiate-model)\n",
@@ -612,7 +613,10 @@
612613
"det_ov_model = core.read_model(det_model_path)\n",
613614
"if device.value != \"CPU\":\n",
614615
" det_ov_model.reshape({0: [1, 3, 640, 640]})\n",
615-
"det_compiled_model = core.compile_model(det_ov_model, device.value)\n",
616+
"ov_config = {}\n",
617+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
618+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
619+
"det_compiled_model = core.compile_model(det_ov_model, device.value, ov_config)\n",
616620
"\n",
617621
"\n",
618622
"def detect(image:np.ndarray, model:ov.Model):\n",
@@ -1147,7 +1151,9 @@
11471151
"source": [
11481152
"if device.value != \"CPU\":\n",
11491153
" quantized_det_model.reshape({0: [1, 3, 640, 640]})\n",
1150-
"quantized_det_compiled_model = core.compile_model(quantized_det_model, device.value)\n",
1154+
"if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
1155+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
1156+
"quantized_det_compiled_model = core.compile_model(quantized_det_model, device.value, ov_config {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"} )\n",
11511157
"input_image = np.array(Image.open(IMAGE_PATH))\n",
11521158
"detections = detect(input_image, quantized_det_compiled_model)[0]\n",
11531159
"image_with_boxes = draw_results(detections, input_image, label_map)\n",
@@ -1706,7 +1712,10 @@
17061712
" player = None\n",
17071713
" if device != \"CPU\":\n",
17081714
" model.reshape({0: [1, 3, 640, 640]})\n",
1709-
" compiled_model = core.compile_model(model, device)\n",
1715+
" ov_config = {}\n",
1716+
" if \"GPU\" in device.value or (\"AUTO\" in device.value and \"GPU\" in core.available_devices):\n",
1717+
" ov_config = {\"GPU_DISABLE_WINOGRAD_CONVOLUTION\": \"YES\"}\n",
1718+
" compiled_model = core.compile_model(model, device, ov_config)\n",
17101719
" try:\n",
17111720
" # Create a video player to play with target fps.\n",
17121721
" player = VideoPlayer(\n",
@@ -1885,7 +1894,7 @@
18851894
],
18861895
"metadata": {
18871896
"kernelspec": {
1888-
"display_name": "Python 3",
1897+
"display_name": "Python 3 (ipykernel)",
18891898
"language": "python",
18901899
"name": "python3"
18911900
},
@@ -1930,4 +1939,4 @@
19301939
},
19311940
"nbformat": 4,
19321941
"nbformat_minor": 5
1933-
}
1942+
}

0 commit comments

Comments
 (0)