Skip to content

Commit

Permalink
Show device name in _print_compiled_model_properties (#541)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Change check for gpu device

---------

Co-authored-by: Ella Charlaix <[email protected]>
  • Loading branch information
helena-intel and echarlaix authored Mar 12, 2024
1 parent 6faf445 commit 358f389
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion optimum/intel/openvino/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def compile(self):
if (
"CACHE_DIR" not in self.ov_config.keys()
and not str(self.model_save_dir).startswith(gettempdir())
and self._device.lower() == "gpu"
and "gpu" in self._device.lower()
):
# Set default CACHE_DIR only if it is not set, if the model is not in a temporary directory, and device is GPU
cache_dir = Path(self.model_save_dir).joinpath("model_cache")
Expand Down
2 changes: 1 addition & 1 deletion optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def _compile(self):
if (
"CACHE_DIR" not in self.ov_config.keys()
and not str(self._model_dir).startswith(gettempdir())
and self.device.lower() == "gpu"
and self.device.lower().split(":")[0] == "gpu"
):
self.ov_config["CACHE_DIR"] = os.path.join(self._model_dir, self._model_name, "model_cache")

Expand Down
4 changes: 2 additions & 2 deletions optimum/intel/openvino/modeling_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def _compile(self):
if (
"CACHE_DIR" not in ov_config.keys()
and not str(self.parent_model.model_save_dir).startswith(gettempdir())
and self._device.lower() == "gpu"
and "gpu" in self._device.lower()
):
cache_dir = Path(self.parent_model.model_save_dir).joinpath("model_cache")
ov_config["CACHE_DIR"] = str(cache_dir)
Expand Down Expand Up @@ -563,7 +563,7 @@ def _compile(self):
if (
"CACHE_DIR" not in ov_config.keys()
and not str(self.parent_model.model_save_dir).startswith(gettempdir())
and self._device.lower() == "gpu"
and "gpu" in self._device.lower()
):
cache_dir = Path(self.parent_model.model_save_dir).joinpath("model_cache")
ov_config["CACHE_DIR"] = str(cache_dir)
Expand Down
8 changes: 7 additions & 1 deletion optimum/intel/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy as np
from huggingface_hub import model_info
from openvino.runtime import Type, properties
from openvino.runtime import Core, Type, properties
from transformers.onnx.utils import ParameterFormat, compute_serialized_parameters_size


Expand Down Expand Up @@ -155,3 +155,9 @@ def _print_compiled_model_properties(compiled_model):
logger.info(f" {k}: {value}")
except Exception:
logger.error(f"[error] Get property of '{k}' failed")
try:
logger.info("EXECUTION_DEVICES:")
for device in compiled_model.get_property("EXECUTION_DEVICES"):
logger.info(f" {device}: {Core().get_property(device, 'FULL_DEVICE_NAME')}")
except Exception:
logger.error("[error] Get FULL_DEVICE_NAME failed")

0 comments on commit 358f389

Please sign in to comment.