Skip to content

Commit f68486b

Browse files
helena-intelecharlaix
authored andcommitted
Show device name in _print_compiled_model_properties (huggingface#541)
* Show device name in _print_compiled_model_properties Enable CACHE_DIR also for devices like "GPU:0" * Update optimum/intel/openvino/modeling_seq2seq.py Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com> * Change check for gpu device --------- Co-authored-by: Ella Charlaix <80481427+echarlaix@users.noreply.github.com>
1 parent 345f9e5 commit f68486b

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

optimum/intel/openvino/modeling_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def compile(self):
388388
if (
389389
"CACHE_DIR" not in self.ov_config.keys()
390390
and not str(self.model_save_dir).startswith(gettempdir())
391-
and self._device.lower() == "gpu"
391+
and "gpu" in self._device.lower()
392392
):
393393
# Set default CACHE_DIR only if it is not set, if the model is not in a temporary directory, and device is GPU
394394
cache_dir = Path(self.model_save_dir).joinpath("model_cache")

optimum/intel/openvino/modeling_diffusion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def _compile(self):
669669
if (
670670
"CACHE_DIR" not in self.ov_config.keys()
671671
and not str(self._model_dir).startswith(gettempdir())
672-
and self.device.lower() == "gpu"
672+
and self.device.lower().split(":")[0] == "gpu"
673673
):
674674
self.ov_config["CACHE_DIR"] = os.path.join(self._model_dir, self._model_name, "model_cache")
675675

optimum/intel/openvino/modeling_seq2seq.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def _compile(self):
451451
if (
452452
"CACHE_DIR" not in ov_config.keys()
453453
and not str(self.parent_model.model_save_dir).startswith(gettempdir())
454-
and self._device.lower() == "gpu"
454+
and "gpu" in self._device.lower()
455455
):
456456
cache_dir = Path(self.parent_model.model_save_dir).joinpath("model_cache")
457457
ov_config["CACHE_DIR"] = str(cache_dir)
@@ -563,7 +563,7 @@ def _compile(self):
563563
if (
564564
"CACHE_DIR" not in ov_config.keys()
565565
and not str(self.parent_model.model_save_dir).startswith(gettempdir())
566-
and self._device.lower() == "gpu"
566+
and "gpu" in self._device.lower()
567567
):
568568
cache_dir = Path(self.parent_model.model_save_dir).joinpath("model_cache")
569569
ov_config["CACHE_DIR"] = str(cache_dir)

optimum/intel/openvino/utils.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import numpy as np
2222
from huggingface_hub import model_info
23-
from openvino.runtime import Type, properties
23+
from openvino.runtime import Core, Type, properties
2424
from transformers.onnx.utils import ParameterFormat, compute_serialized_parameters_size
2525

2626

@@ -155,3 +155,9 @@ def _print_compiled_model_properties(compiled_model):
155155
logger.info(f" {k}: {value}")
156156
except Exception:
157157
logger.error(f"[error] Get property of '{k}' failed")
158+
try:
159+
logger.info("EXECUTION_DEVICES:")
160+
for device in compiled_model.get_property("EXECUTION_DEVICES"):
161+
logger.info(f" {device}: {Core().get_property(device, 'FULL_DEVICE_NAME')}")
162+
except Exception:
163+
logger.error("[error] Get FULL_DEVICE_NAME failed")

0 commit comments

Comments
 (0)