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

[WIP] Feature: Add in hardware acceleration through VAAPI #40

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

jshridha
Copy link
Owner

@jshridha jshridha commented Dec 6, 2020

Currently tested and working for Intel GPUs. Below is an example docker compose yaml file:

version: "3.7"
services:
  blueiris:
    container_name: blueiris
    privileged: true
    restart: always
    image: jshridha/blueiris:gpu
    init: true
    devices:
      - /dev/dri:/dev/dri
    environment:
      - LIBVA_DRIVER_NAME=iHD
    ports:
      - "8080:8080"
      - "5900:5900"
      - "8081:8081"
    volumes:
      - ./data:/home/wineuser/prefix:rw
      - /etc/localtime:/etc/localtime:ro

You'll need to 1.) have a clean environment, 2.) set proper permissions on data directory (chown 1000:100 data), and 3.) Run winecfg as wineuser and turn on VAAPI in the staging tab. To do this run the following command after the container is up and running: docker exec -it blueiris su wineuser -s /bin/bash winecfg

Todos:

  1. Testing for AMD/Nvidia GPUs also. Will need to change LIBVA_DRIVER_NAME to match the right card. I'll need some help here as I don't have good access to modern AMD/NVIDIA gpus.
  2. Documentation on how to get this up and running

@stefanvanherwijnen
Copy link

As far as I know Blue Iris only supports Intel Quick Sync.
Apparently Nvidia CUDA is also supported now but not recommended (https://ipcamtalk.com/wiki/choosing-hardware-for-blue-iris/).

I tried using libva-intel-driver with LIBVA_DRIVER_NAME=i915 which also seems to work, but I think intel-media-driver is the better option: https://wiki.archlinux.org/index.php/Hardware_video_acceleration#VA-API_drivers

@stefanvanherwijnen
Copy link

I have been using the following which seems to work great for hardware acceleration (just have to make sure to have intel-media-driver installed and check if VAAPI is available with vainfo):

version: "3.7"
services:
  blueiris:
    container_name: blueiris
    privileged: true
    restart: unless-stopped
    image: jshridha/blueiris:gpu
    init: true
    devices:
      - /dev/dri:/dev/dri
    environment:
      - LIBVA_DRIVER_NAME=iHD
    ports:
      - "7080:8080"
      - "5900:5900"
      - "7081:8081"
    volumes:
      - ./prefix:/home/wineuser/prefix:rw
      - /etc/localtime:/etc/localtime:ro
#    command: -c /etc/supervisor/conf.d/supervisord-service.conf
    logging:
      options:
        max-size: "5M"
        max-file: "10"

The only thing which I cannot get to work is the 'run as a service'. Using the command line and recreating the container does not seem to work, i.e. the web server is not accessible. I've tried the suggestions in the 'run as a service' PR which did not seem to work so maybe it's something specific to this branch?

@jshridha
Copy link
Owner Author

It's definitely specific to this branch. I got rid of the "run as service" feature because you can't use GPU acceleration + that feature at the same time. The only reason we switched to running as a service was to get the timezone to be properly displayed in BI, but that issue is now fixed in this branch.

Did you change the webserver port to 8081 in the web gui in BI? Is BI running if you VNC into the container?

@stefanvanherwijnen
Copy link

stefanvanherwijnen commented Jan 21, 2021

Yes, in normal mode it works fine but in service mode it doesn't work at all (which makes sense now).
The only problem with normal mode is that Blue Iris doesn't restart upon a crash. Changing autorestart to true in the supervisor file for the blueiris service seems to fix this, but I thought that the recommended approach would be to use the service mode.

On initial setup it would crash daily but I just remember a comment in the 'run as a service' PR that continuously recording with overlay enabled would cause crashes. In hindsight, after disabling the overlay it worked fine for a week but eventually it did crash.

Edit: It seems Windows likes to report errors in a window (Blue Iris has encountered a serious error) which also prevents the process from restarting.

@anonymous-one
Copy link

anonymous-one commented Apr 27, 2021

In order to get my timezone to display correctly I had to remove the TZ env export.

@juan11perez
Copy link

juan11perez commented May 21, 2021

Good day, thank you for producing and sharing this docker.
I run unraid and tried testing gpu with nvidia as such:

    container_name: blueiris
    image: jshridha/blueiris:gpu
    restart: unless-stopped
    hostname: UNRAID  
    privileged: true 
    runtime: nvidia    
    init: true
    volumes:
    - /mnt/cache/appdata/blueiris/conf:/home/wineuser/prefix:rw
    - /mnt/cache/appdata/blueiris/data:/srv:rw 
    - /etc/localtime:/etc/localtime:ro
    devices:
    - /dev/dri:/dev/dri
    ports:
    - 8280:8080
    - 5909:5900 # VNC Port
    - 8181:81 # WebUI Port
    labels:
    - "com.centurylinklabs.watchtower.enable=true"     
    logging:
      options:
        max-size: "5m"
        max-file: "2"
    environment:
    - NVIDIA_VISIBLE_DEVICES=GPU-0d460ee2-906e-cd35-c793-056a35ffba80
    - NVIDIA_DRIVER_CAPABILITIES=all
    - LIBVA_DRIVER_NAME=vdpau
    - VDPAU_DRIVER=nvidia```



The container came up and followed your docker exec -it blueiris su wineuser -s /bin/bash winecfg instruction selecting the vaapi option in the stage-tab as there's no nvidia option. should i manually install the nvidia drivers in the docker ??

One issue I noticed is that the /ui3.htm server doesn't work.

I also tried the dev branch and the /ui3.htm server doesnt work either.

@stefanvanherwijnen
Copy link

I don't know about the Nvidia gpu, but I think UI3 is the default web interface in Blue Iris (there is an option somewhere in the settings). You shouldn't have to add /ui3.htm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants