Skip to content

Commit a486351

Browse files
authored
Merge pull request #173 from intel/linux_dev
Updates for Linux compatiblity
2 parents 2627091 + dc4a23e commit a486351

File tree

3 files changed

+21
-47
lines changed

3 files changed

+21
-47
lines changed

Docs/linux_install_guide.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ More details can be found [here](https://github.com/snapcrafters/gimp/tree/previ
3434
```sh
3535
git clone https://gitlab.gnome.org/GNOME/babl
3636
cd babl
37-
git checkout tags/BABL_0_1_110
37+
git checkout tags/BABL_0_1_112
3838
meson _build
3939
ninja -C _build
4040
sudo ninja -C _build install
@@ -44,7 +44,7 @@ More details can be found [here](https://github.com/snapcrafters/gimp/tree/previ
4444
```sh
4545
git clone https://gitlab.gnome.org/GNOME/gegl
4646
cd gegl
47-
git checkout tags/GEGL_0_4_52
47+
git checkout tags/GEGL_0_4_58
4848
meson _build
4949
ninja -C _build
5050
sudo ninja -C _build install
@@ -55,7 +55,7 @@ More details can be found [here](https://github.com/snapcrafters/gimp/tree/previ
5555
```sh
5656
git clone https://gitlab.gnome.org/GNOME/gimp
5757
cd gimp
58-
git checkout tags/GIMP_3_0_0_RC2
58+
git checkout tags/GIMP_3_0_2
5959
git submodule update --init
6060
export GI_TYPELIB_PATH=/usr/lib/x86_64-linux-gnu/girepository-1.0:/usr/local/lib/x86_64-linux-gnu/girepository-1.0
6161
meson _build
@@ -80,7 +80,8 @@ More details can be found [here](https://github.com/snapcrafters/gimp/tree/previ
8080
Start GIMP, ensuring to setup the environment variables correctly, and you should see 'OpenVINO-AI-Plugins' show up in 'Layer' menu
8181
```sh
8282
export GI_TYPELIB_PATH=/usr/lib/x86_64-linux-gnu/girepository-1.0:/usr/local/lib/x86_64-linux-gnu/girepository-1.0
83-
gimp
83+
export LD_LIBRARY_PATH=/usr/local/lib/x86_64-linux-gnu
84+
gimp-3
8485
```
8586

8687

gimpopenvino/install_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import openvino as ov
2121
from gimpopenvino.plugins.openvino_utils.tools.tools_utils import base_model_dir, config_path_dir
2222

23-
# Enum for NPU Arch
23+
# Enum for NPU Arch -
2424
class NPUArchitecture(Enum):
2525
ARCH_3700 = "3700" # Keem Bay
2626
ARCH_3720 = "3720" # Meteor Lake and Arrow Lake
2727
ARCH_4000 = "4000" # Lunar Lake
28+
ARCH_NONE = "0000" # No NPU
2829
ARCH_NEXT = "FFFF" # Next Lake
2930

3031

@@ -87,10 +88,11 @@ def get_npu_architecture(core):
8788
return NPUArchitecture.ARCH_NEXT
8889
else:
8990
return NPUArchitecture.ARCH_3700
90-
return None
91+
return NPUArchitecture.ARCH_NONE
92+
9193
except Exception as e:
9294
logging.error(f"Error retrieving NPU architecture: {str(e)}")
93-
return None
95+
return NPUArchitecture.ARCH_NONE
9496

9597
def get_plugin_version(file_dir=None):
9698
"""

gimpopenvino/plugins/openvino_utils/tools/model_manager.py

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
import threading
1717
from pathlib import Path
1818
from tqdm import tqdm
19+
import time
20+
1921
logging.basicConfig(format='%(message)s', level=logging.INFO, stream=sys.stdout)
2022

2123
sys.path.extend([os.path.join(os.path.dirname(os.path.realpath(__file__)), "openvino_common")])
2224
sys.path.extend([os.path.join(os.path.dirname(os.path.realpath(__file__)), "..","tools")])
2325
from models_ov import (stable_diffusion_engine_genai)
24-
26+
from gimpopenvino.install_utils import *
2527

2628

2729
# This dictionary is used to populate the drop-down model selection list.
@@ -299,13 +301,6 @@
299301

300302
access_token = None
301303

302-
# Enum for NPU Arch
303-
class NPUArchitecture(Enum):
304-
ARCH_3700 = "3700" # Keem Bay
305-
ARCH_3720 = "3720" # Meteor Lake and Arrow Lake
306-
ARCH_4000 = "4000" # Lunar Lake
307-
ARCH_NEXT = "FFFF" # Next Lake
308-
309304
NPU_THRESHOLD = 43000
310305

311306
def does_filename_match_patterns(filename, patterns):
@@ -371,34 +366,9 @@ def download_file_with_progress(url, local_filename, callback, total_bytes_downl
371366
if callback(total_bytes_downloaded, total_file_list_size):
372367
return downloaded_size
373368

369+
time.sleep(0.5) # give large files a chance to sync in their target directory.
374370
return downloaded_size
375371

376-
def get_npu_architecture(core):
377-
"""
378-
Retrieves the NPU architecture using the OpenVINO core.
379-
380-
Args:
381-
core (ov.Core): The OpenVINO core instance.
382-
383-
Returns:
384-
NPUArchitecture: The detected architecture, or None if not found.
385-
"""
386-
try:
387-
available_devices = core.get_available_devices()
388-
if 'NPU' in available_devices:
389-
architecture = core.get_property('NPU', 'DEVICE_ARCHITECTURE')
390-
for arch in NPUArchitecture:
391-
if arch.value in architecture:
392-
return arch
393-
if core.get_property("NPU", "DEVICE_GOPS")[ov.Type.i8] > 0:
394-
return NPUArchitecture.ARCH_NEXT
395-
else:
396-
return NPUArchitecture.ARCH_3700
397-
return None
398-
except Exception as e:
399-
logging.error(f"Error retrieving NPU architecture: {str(e)}")
400-
return None
401-
402372
def get_npu_driver_version(core):
403373
try:
404374
available_devices = core.get_available_devices()
@@ -428,7 +398,7 @@ def __init__(self, weight_path):
428398
self._npu_driver_version = get_npu_driver_version(self._core)
429399
self._weight_path = weight_path
430400
self._install_location = os.path.join(self._weight_path, "stable-diffusion-ov")
431-
self._npu_is_available = True if self._npu_arch is not NPUArchitecture.ARCH_3700 and self._npu_arch is not None else False
401+
self._npu_is_available = True if self._npu_arch is not NPUArchitecture.ARCH_3700 and self._npu_arch is not NPUArchitecture.ARCH_NONE else False
432402
self.show_hf_download_tqdm = False
433403

434404
self.hf_api = HfApi()
@@ -536,7 +506,7 @@ def is_model_installed(self, model_id):
536506
print(f"{model_id} installation folder exists, but it is missing {required_bin_path}")
537507
return False
538508

539-
print("model_id",model_id)
509+
#print("model_id",model_id)
540510
if "sd_3.0_med" in model_id or "sd_3.5_med" in model_id:
541511
install_subdir = g_supported_model_map[model_id]["install_subdir"]
542512
full_install_path = os.path.join(self._weight_path, *install_subdir)
@@ -885,12 +855,10 @@ def _download_model(self, model_id):
885855
else:
886856
os.makedirs(full_install_path)
887857

888-
print("Inpainting optimun-cli full install path",full_install_path)
858+
#print("optimun-cli full install path",full_install_path)
889859
import subprocess
890860

891-
892-
ppath = sys.executable
893-
optimum_ex = ppath.replace("python.exe","optimum-cli.exe")
861+
optimum_ex = sys.executable.replace("python", "optimum-cli").replace("optimum-cli3", "optimum-cli")
894862

895863
output_file = Path(os.path.join(full_install_path, "export_output.log"))
896864
if(model_id != "sd_15_inpainting"):
@@ -914,6 +882,7 @@ def _download_model(self, model_id):
914882

915883
# Specify the file name
916884
file_name = "config.json"
885+
os.makedirs(os.path.dirname(full_install_path), exist_ok=True)
917886

918887
# Write the data to a JSON file
919888
with open(os.path.join(full_install_path,file_name), 'w') as json_file:
@@ -933,6 +902,8 @@ def _download_model(self, model_id):
933902
if os.path.isdir(download_folder):
934903
shutil.rmtree(download_folder, ignore_errors=True)
935904

905+
906+
936907
# To cache these models upfront as it takes a lot of time to load.
937908
if "sdxl_turbo" in model_id:
938909
model_name="sdxl_turbo_square"

0 commit comments

Comments
 (0)