Skip to content

Commit 359d0d6

Browse files
frenchwrjnsgruk
andauthored
feat: enable OpenVINO AI Plugins (#325)
* feature: integrate OpenVINO AI plugins * ci: update workflows for 2.99-openvino track * readme: remove TODOs and improve setup instructions * fix: remove arch hard-coding * feature: switch to personal-files interface as a less intrusive location for models * fix: add plug-declaration to unblock build * fix: use fixed source for command-chain scripts * readme: remove section for manually connecting plugs * fix: minor plug-in and extension errors from logs * fix: avoid lua goat extension crash loop * chore: bump versions of command-chain scripts for openvino ai plugins support * chore: update 2.99 paths and commands to 3.0 * readme: update instructions for preview branch * chore: bump ai plugins command-chain version for 3.0 support * chore: revert CI to preview branches * fix: pull new command-chain scripts for arm64 issues * chore: make openvino command-chain scripts no-ops for arm64 * chore: bump openvino command chain versions for better hardware detection * readme: clarify details about hardware requirements for AI plugins --------- Co-authored-by: Jon Seager <[email protected]> Co-authored-by: Jon Seager <[email protected]>
1 parent 9d45d5c commit 359d0d6

File tree

3 files changed

+129
-7
lines changed

3 files changed

+129
-7
lines changed

.github/plug-declaration.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"personal-files": { "allow-installation": "true" }
3+
}

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,55 @@ Now that your git metadata has been updated you are ready to create a bugfix bra
7878
6. Someone from the team will review the open pull request and either merge it or start a discussion with you with additional changes or clarification needed.
7979
7. Once the pull request has been merged into the stable branch, a GitHub action will rebuild the snap using your changes and publish it to the [Snap Store](https://snapcraft.io/gimp) into the `candidate` channel. After sufficient testing of the snap from the candidate channel, one of the maintainers or administrators will promote the snap to the stable branch in the Snap Store.
8080
81+
## OpenVINO™ AI Plugins
82+
83+
> [!IMPORTANT]
84+
> These plugins are only supported on Intel hardware. The stable diffusion plugin requires an Intel GPU (integrated or discrete) and/or Intel NPU. The super resolution and semantic segmentation plugins will run on an Intel CPU, GPU, or NPU.
85+
86+
This snap contains support for AI plugins using Intel's OpenVINO AI inference library. In order to use these plugins, please follow these steps:
87+
88+
89+
1. **Install the plugins and their dependencies**:
90+
91+
```shell
92+
sudo snap install intel-npu-driver --beta # for NPU support
93+
sudo snap install openvino-toolkit-2404 --beta
94+
sudo snap install openvino-ai-plugins-gimp --beta
95+
```
96+
97+
2. **(Optional) Enable Intel NPU and GPU acceleration**:
98+
99+
If you are running on a machine (e.g. a laptop or desktop containing an Intel Core Ultra processor) equipped with an Intel neural processing unit (NPU) or graphics processing unit (GPU), ensure you have permissions to use these devices by adding yourself to the `render` Unix group:
100+
101+
```shell
102+
sudo usermod -a -G render $USER
103+
```
104+
105+
You need to log out and log back for this change to take effect.
106+
107+
Next, ensure that the devices have read and write permissions set on the group level:
108+
109+
```shell
110+
sudo chown root:render /dev/accel/accel*
111+
sudo chmod g+rw /dev/accel/accel*
112+
sudo chown root:render /dev/dri/render*
113+
sudo chmod g+rw /dev/dri/render*
114+
```
115+
116+
3. **(Optional) Install stable diffusion models**:
117+
118+
Models for the super resolution and semantic segmentation plugins are relatively small and therefore built into the snap, while the stable diffusion models are each on the order of GBs and therefore downloaded to a user's home directory at `~/.local/share/openvino-ai-plugins-gimp` via one of two methods: a `model-setup` command-line tool or from within the GIMP application. To run the interactive command-line tool:
119+
120+
```shell
121+
openvino-ai-plugins-gimp.model-setup
122+
```
123+
124+
Alternatively, users may download models from within GIMP by clicking "Model" in the top-left of the stable diffusion dialog window (Layer -> OpenVINO-AI-Plugins -> Stable Diffusion).
125+
126+
4. **Run `gimp` like normal**:
127+
128+
Instructions for using the OpenVINO AI plugins within GIMP can be found in the [upstream GitHub repo](https://github.com/intel/openvino-ai-plugins-gimp).
129+
81130
## Maintainers
82131
83132
- [@lucyllewy](https://github.com/lucyllewy/)

snap/snapcraft.yaml

+77-7
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,52 @@ layout:
2626
/usr/share/locale:
2727
bind: $SNAP/usr/share/locale
2828

29-
plugs:
30-
ffmpeg-2404:
31-
interface: content
32-
target: ffmpeg-platform
33-
default-provider: ffmpeg-2404
34-
3529
slots:
3630
dbus-gimp:
3731
interface: dbus
3832
bus: session
3933
name: org.gimp.GIMP.UI
4034

35+
plugs:
36+
ffmpeg-2404:
37+
interface: content
38+
target: ffmpeg-platform
39+
default-provider: ffmpeg-2404
40+
intel-npu:
41+
interface: custom-device
42+
custom-device: intel-npu-device
43+
npu-libs:
44+
interface: content
45+
content: npu-libs-2404
46+
target: $SNAP/npu-libs
47+
openvino-libs:
48+
interface: content
49+
content: openvino-libs-2404
50+
target: $SNAP/openvino
51+
openvino-ai-plugins-gimp-libs:
52+
interface: content
53+
content: openvino-ai-plugins-gimp-2404
54+
target: $SNAP/openvino-ai-plugins-gimp
55+
dot-local-share-openvino-ai-plugins-gimp:
56+
interface: personal-files
57+
write:
58+
- $HOME/.local/share/openvino-ai-plugins-gimp
59+
4160
environment:
4261
GI_TYPELIB_PATH: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gjs/girepository-1.0:$GI_TYPELIB_PATH
43-
LD_LIBRARY_PATH: $SNAP/lib:$SNAP/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/gnome-platform/usr/lib:$SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/usr/lib:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas
62+
LD_LIBRARY_PATH: $SNAP/lib:$SNAP/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/gnome-platform/usr/lib:$SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/usr/lib:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas:$SNAP/npu-libs
4463
# Ensure the gmic plugin can correctly locate the QT plugins
4564
QT_PLUGIN_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/qt6/plugins
65+
GIMP3_LOCALEDIR: $SNAP/usr/share/locale
66+
# Lua goat exercise considered unstable upstream: https://gitlab.gnome.org/GNOME/gimp/-/commit/78665ca3723f723ac313fdaeef5b62d41ab6b48d
67+
# The extension will fail on GIMP startup but commenting these lines avoids the risk of a nasty crash loop
68+
#LUA_PATH: $SNAP/usr/share/lua/5.1/?.lua;$SNAP/usr/share/lua/5.1/lgi/?.lua;$SNAP/usr/share/lua/5.1/lgi/override/?.lua
69+
#LUA_CPATH: $SNAP/usr/lib/x86_64-linux-gnu/lua/5.1/?.so
4670

4771
apps:
4872
gimp:
4973
command: usr/bin/gimp
74+
command-chain: ["command-chain/openvino-launch", "command-chain/openvino-ai-plugins-gimp-launch"]
5075
extensions: [gnome]
5176
desktop: usr/share/applications/gimp.desktop
5277
common-id: org.gimp.GIMP
@@ -63,6 +88,11 @@ apps:
6388
- network
6489
- removable-media
6590
- unity7
91+
- intel-npu
92+
- npu-libs
93+
- openvino-libs
94+
- openvino-ai-plugins-gimp-libs
95+
- dot-local-share-openvino-ai-plugins-gimp
6696

6797
parts:
6898
babl:
@@ -230,6 +260,46 @@ parts:
230260
- mypaint-brushes
231261
- mypaint-data
232262
- poppler-data
263+
override-stage: |
264+
# fix gimp python interpreters file
265+
cat <<EOF > ${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gimp/3.0/interpreters/pygimp.interp
266+
python=/usr/bin/python3
267+
python3=/usr/bin/python3
268+
/usr/bin/python=/usr/bin/python3
269+
/usr/bin/python3=/usr/bin/python3
270+
:Python:E::py::python3:
271+
EOF
272+
# update gimp's plugin search path so it will pick up plugins mounted over snapd's content interface
273+
current_path=$(grep "# (plug-in-path" ${CRAFT_PART_INSTALL}/etc/gimp/3.0/gimprc | cut -d '"' -f2)
274+
add_dir=/snap/${SNAPCRAFT_PROJECT_NAME}/current/openvino-ai-plugins-gimp/gimp-plugins
275+
echo "(plug-in-path \"${current_path}:${add_dir}\")" >> ${CRAFT_PART_INSTALL}/etc/gimp/3.0/gimprc
276+
craftctl default
277+
278+
command-chain-openvino:
279+
plugin: dump
280+
source-type: git
281+
source: https://github.com/canonical/openvino-toolkit-snap.git
282+
source-tag: 2024.6.0-4
283+
stage:
284+
- command-chain/openvino-launch
285+
override-stage: |
286+
if [ $(uname -m) != "x86_64" ]; then
287+
echo 'exec "$@"' > ${CRAFT_PART_INSTALL}/command-chain/openvino-launch
288+
fi
289+
craftctl default
290+
291+
command-chain-openvino-ai-plugins-gimp:
292+
plugin: dump
293+
source-type: git
294+
source: https://github.com/canonical/openvino-ai-plugins-gimp-snap.git
295+
source-branch: 3.0.0-2
296+
stage:
297+
- command-chain/openvino-ai-plugins-gimp-launch
298+
override-stage: |
299+
if [ $(uname -m) != "x86_64" ]; then
300+
echo 'exec "$@"' > ${CRAFT_PART_INSTALL}/command-chain/openvino-ai-plugins-gimp-launch
301+
fi
302+
craftctl default
233303
234304
gmic:
235305
after: [gimp]

0 commit comments

Comments
 (0)