Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ml)!: cuda and openvino acceleration #5619

Merged
merged 41 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e1199da
cuda and openvino ep, refactor, update dockerfile
mertalev Dec 10, 2023
54168a7
updated workflow
mertalev Dec 10, 2023
6c9727b
typing fixes
mertalev Dec 10, 2023
6f72745
added tests
mertalev Dec 10, 2023
80801be
updated ml test gh action
mertalev Dec 10, 2023
713e28c
updated README
mertalev Dec 10, 2023
88b95f9
updated docker-compose
mertalev Dec 10, 2023
0d9058f
added compute to hwaccel.yml
mertalev Dec 11, 2023
4610d39
updated gh matrix
mertalev Dec 11, 2023
c1ab88e
remove cuda/arm64 build
mertalev Dec 11, 2023
d032e0f
add hwaccel image tags to docker-compose
mertalev Dec 14, 2023
f9f5e38
remove unnecessary quotes
mertalev Dec 14, 2023
48ee252
add suffix to git tag
mertalev Dec 14, 2023
2a19de7
fixed kwargs in base model
mertalev Dec 15, 2023
7d40e16
armnn ld_library_path
mertalev Dec 21, 2023
f8a40cf
update pyproject.toml
mertalev Dec 21, 2023
a441add
add armnn workflow
mertalev Dec 21, 2023
a9973e9
formatting
mertalev Dec 21, 2023
9b4f29f
consolidate hwaccel files, update docker compose
mertalev Dec 22, 2023
9e6cbcd
update hw transcoding docs
mertalev Dec 22, 2023
233dfbe
add ml hwaccel docs
mertalev Dec 22, 2023
4b2899c
update dev and prod docker-compose
mertalev Dec 22, 2023
0611a5e
added armnn prerequisite docs
mertalev Dec 22, 2023
6b9f071
support 3.10
mertalev Dec 23, 2023
7a2fc6f
updated docker-compose comments
mertalev Jan 13, 2024
d8db13b
formatting
mertalev Jan 13, 2024
35ef695
test coverage
mertalev Jan 13, 2024
8b332c9
don't set arena extend strategy for openvino
mertalev Jan 13, 2024
94afa26
working openvino
mertalev Jan 13, 2024
719667d
formatting
mertalev Jan 13, 2024
7f684e2
fix dockerfile
mertalev Jan 13, 2024
0df73ba
added type annotation
mertalev Jan 13, 2024
55a5675
add wsl configuration for openvino
mertalev Jan 13, 2024
7395dd0
updated lock file
mertalev Jan 13, 2024
1eb305e
copy python3
mertalev Jan 18, 2024
6e7bd55
comment out extends section
mertalev Jan 18, 2024
0a30e98
fix platforms
mertalev Jan 18, 2024
8440f05
simplify workflow suffix tagging
mertalev Jan 18, 2024
f6c2b2b
simplify aio transcoding doc
mertalev Jan 20, 2024
665e676
update docs and workflow for `hwaccel.yml` change
mertalev Jan 20, 2024
b68f17e
revert docs
mertalev Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,38 @@ jobs:
fail-fast: false
matrix:
include:
- context: "machine-learning"
file: "machine-learning/Dockerfile"
image: "immich-machine-learning"
platforms: "linux/amd64,linux/arm64"
- context: "."
file: "server/Dockerfile"
image: "immich-server"
platforms: "linux/arm64,linux/amd64"
- image: immich-machine-learning
context: machine-learning
file: machine-learning/Dockerfile
platforms: linux/amd64,linux/arm64
device: cpu

- image: immich-machine-learning
context: machine-learning
file: machine-learning/Dockerfile
platforms: linux/amd64
device: cuda
suffix: -cuda

- image: immich-machine-learning
context: machine-learning
file: machine-learning/Dockerfile
platforms: linux/amd64
device: openvino
suffix: -openvino

- image: immich-machine-learning
context: machine-learning
file: machine-learning/Dockerfile
platforms: linux/arm64
device: armnn
suffix: -armnn

- image: immich-server
context: .
file: server/Dockerfile
platforms: linux/amd64,linux/arm64
device: cpu
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -79,12 +102,12 @@ jobs:
name=altran1502/${{matrix.image}},enable=${{ github.event_name == 'release' }}
tags: |
# Tag with branch name
type=ref,event=branch
type=ref,event=branch,suffix=${{ matrix.suffix }}
# Tag with pr-number
type=ref,event=pr
type=ref,event=pr,suffix=${{ matrix.suffix }}
# Tag with git tag on release
type=ref,event=tag
type=raw,value=release,enable=${{ github.event_name == 'release' }}
type=ref,event=tag,suffix=${{ matrix.suffix }}
type=raw,value=release,enable=${{ github.event_name == 'release' }},suffix=${{ matrix.suffix }}

- name: Determine build cache output
id: cache-target
Expand All @@ -106,5 +129,7 @@ jobs:
push: ${{ !github.event.pull_request.head.repo.fork }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/immich-build-cache:${{matrix.image}}
cache-to: ${{ steps.cache-target.outputs.cache-to }}
build-args: |
DEVICE=${{ matrix.device }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
3 changes: 2 additions & 1 deletion .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ jobs:
files: |
docker/docker-compose.yml
docker/example.env
docker/hwaccel.yml
docker/hwaccel.ml.yml
docker/hwaccel.transcoding.yml
*.apk
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:
cache: "poetry"
- name: Install dependencies
run: |
poetry install --with dev
poetry install --with dev --with cpu
- name: Lint with ruff
run: |
poetry run ruff check --output-format=github app export
Expand Down
9 changes: 7 additions & 2 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ services:
command: [ "/usr/src/app/bin/immich-dev", "microservices" ]
<<: *server-common
# extends:
# file: hwaccel.yml
# service: hwaccel
# file: hwaccel.transcoding.yml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
ports:
- 9231:9230
depends_on:
Expand Down Expand Up @@ -79,9 +79,14 @@ services:
immich-machine-learning:
container_name: immich_machine_learning
image: immich-machine-learning-dev:latest
# extends:
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference
build:
context: ../machine-learning
dockerfile: Dockerfile
args:
- DEVICE=cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference
ports:
- 3003:3003
volumes:
Expand Down
9 changes: 7 additions & 2 deletions docker/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ services:
command: [ "./start-microservices.sh" ]
<<: *server-common
# extends:
# file: hwaccel.yml
# service: hwaccel
# file: hwaccel.transcoding.yml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
depends_on:
- redis
- database
Expand All @@ -40,9 +40,14 @@ services:
immich-machine-learning:
container_name: immich_machine_learning
image: immich-machine-learning:latest
# extends:
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference
build:
context: ../machine-learning
dockerfile: Dockerfile
args:
- DEVICE=cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference
volumes:
- model-cache:/cache
env_file:
Expand Down
11 changes: 8 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ services:
immich-microservices:
container_name: immich_microservices
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.yml
# service: hwaccel
# extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/hardware-transcoding
# file: hwaccel.transcoding.yml
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
command: [ "start.sh", "microservices" ]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
Expand All @@ -46,7 +46,12 @@ services:

immich-machine-learning:
container_name: immich_machine_learning
# For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
# Example tag: ${IMMICH_VERSION:-release}-cuda
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
# extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
# file: hwaccel.ml.yml
# service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
volumes:
- model-cache:/cache
env_file:
Expand Down
24 changes: 0 additions & 24 deletions docker/hwaccel-rkmpp.yml

This file was deleted.

47 changes: 47 additions & 0 deletions docker/hwaccel.ml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.8"

# Configurations for hardware-accelerated machine learning

# If using Unraid or another platform that doesn't allow multiple Compose files,
# you can inline the config for a backend by copying its contents
# into the immich-machine-learning service in the docker-compose.yml file.

# See https://immich.app/docs/features/ml-hardware-acceleration for info on usage.

services:
armnn:
devices:
- /dev/mali0:/dev/mali0
volumes:
- /lib/firmware/mali_csffw.bin:/lib/firmware/mali_csffw.bin:ro # Mali firmware for your chipset (not always required depending on the driver)
- /usr/lib/libmali.so:/usr/lib/libmali.so:ro # Mali driver for your chipset (always required)

cpu:

cuda:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities:
- gpu
- compute
- video

openvino:
device_cgroup_rules:
- "c 189:* rmw"
devices:
- /dev/dri:/dev/dri
volumes:
- /dev/bus/usb:/dev/bus/usb

openvino-wsl:
devices:
- /dev/dri:/dev/dri
- /dev/dxg:/dev/dxg
volumes:
- /dev/bus/usb:/dev/bus/usb
- /usr/lib/wsl:/usr/lib/wsl
59 changes: 59 additions & 0 deletions docker/hwaccel.transcoding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
version: "3.8"

# Configurations for hardware-accelerated transcoding

# If using Unraid or another platform that doesn't allow multiple Compose files,
# you can inline the config for a backend by copying its contents
# into the immich-microservices service in the docker-compose.yml file.

# See https://immich.app/docs/features/hardware-transcoding for more info on using hardware transcoding.

services:
cpu:

nvenc:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities:
- gpu
- compute
- video

quicksync:
devices:
- /dev/dri:/dev/dri

rkmpp:
security_opt: # enables full access to /sys and /proc, still far better than privileged: true
- systempaths=unconfined
- apparmor=unconfined
group_add:
- video
devices:
- /dev/rga:/dev/rga
- /dev/dri:/dev/dri
- /dev/dma_heap:/dev/dma_heap
- /dev/mpp_service:/dev/mpp_service
volumes:
- /usr/bin/ffmpeg:/usr/bin/ffmpeg_mpp:ro
- /lib/aarch64-linux-gnu:/lib/ffmpeg-mpp:ro
- /lib/aarch64-linux-gnu/libblas.so.3:/lib/ffmpeg-mpp/libblas.so.3:ro # symlink is resolved by mounting
- /lib/aarch64-linux-gnu/liblapack.so.3:/lib/ffmpeg-mpp/liblapack.so.3:ro # symlink is resolved by mounting
- /lib/aarch64-linux-gnu/pulseaudio/libpulsecommon-15.99.so:/lib/ffmpeg-mpp/libpulsecommon-15.99.so:ro

vaapi:
devices:
- /dev/dri:/dev/dri

vaapi-wsl: # use this for VAAPI if you're running Immich in WSL2
devices:
- /dev/dri:/dev/dri
volumes:
- /usr/lib/wsl:/usr/lib/wsl
environment:
- LD_LIBRARY_PATH=/usr/lib/wsl/lib
- LIBVA_DRIVER_NAME=d3d12
22 changes: 0 additions & 22 deletions docker/hwaccel.yml

This file was deleted.

11 changes: 0 additions & 11 deletions docker/mlaccel-armnn.yml

This file was deleted.

Loading
Loading