diff --git a/community-containers/jellyfin/jellyfin.json b/community-containers/jellyfin/jellyfin.json index f54c7b81c4a5..b469c38b6cc6 100644 --- a/community-containers/jellyfin/jellyfin.json +++ b/community-containers/jellyfin/jellyfin.json @@ -28,10 +28,7 @@ "writeable": false } ], - "devices": [ - "/dev/dri" - ], - "nvidia": true, + "enable_gpu": true, "backup_volumes": [ "nextcloud_aio_jellyfin" ] diff --git a/community-containers/memories/memories.json b/community-containers/memories/memories.json index 803156608e8d..baa5a4493bc0 100644 --- a/community-containers/memories/memories.json +++ b/community-containers/memories/memories.json @@ -24,10 +24,7 @@ "writeable": false } ], - "devices": [ - "/dev/dri" - ], - "nvidia": true, + "enable_gpu": true, "nextcloud_exec_commands": [ "php /var/www/html/occ app:install memories", "php /var/www/html/occ app:enable memories", diff --git a/community-containers/plex/plex.json b/community-containers/plex/plex.json index f20222ec44aa..322f4c81fafe 100644 --- a/community-containers/plex/plex.json +++ b/community-containers/plex/plex.json @@ -30,10 +30,7 @@ "writeable": false } ], - "devices": [ - "/dev/dri" - ], - "nvidia": true, + "enable_gpu": true, "backup_volumes": [ "nextcloud_aio_plex" ] diff --git a/php/containers-schema.json b/php/containers-schema.json index ec11f7dbeaf6..a10fd09948ad 100644 --- a/php/containers-schema.json +++ b/php/containers-schema.json @@ -160,7 +160,7 @@ "pattern": "^/dev/[a-z]+$" } }, - "nvidia": { + "enable_gpu": { "type": "boolean" }, "apparmor_unconfined": { diff --git a/php/containers.json b/php/containers.json index b771efcffb38..c7a986094acd 100644 --- a/php/containers.json +++ b/php/containers.json @@ -260,10 +260,7 @@ ], "stop_grace_period": 600, "restart": "unless-stopped", - "devices": [ - "/dev/dri" - ], - "nvidia": true, + "enable_gpu": true, "backup_volumes": [ "nextcloud_aio_nextcloud" ], diff --git a/php/src/Container/Container.php b/php/src/Container/Container.php index 22feceb60493..b30f72d60a2f 100644 --- a/php/src/Container/Container.php +++ b/php/src/Container/Container.php @@ -23,7 +23,7 @@ public function __construct( private array $secrets, /** @var string[] */ private array $devices, - private bool $nvidia, + private bool $enable_gpu, /** @var string[] */ private array $capAdd, private int $shmSize, @@ -93,8 +93,8 @@ public function GetDevices() : array { return $this->devices; } - public function CanUseNvidia() : bool { - return $this->nvidia; + public function GetGpuMode() : bool { + return $this->enable_gpu; } public function GetCapAdds() : array { diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index 9d6566b29c8a..8d04fd6df401 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -249,7 +249,7 @@ private function GetDefinition(): array $devices = $entry['devices']; } - $nvidia = $entry['nvidia'] === true; + $enable_gpu = $entry['enable_gpu'] === true; $capAdd = []; if (isset($entry['cap_add'])) { @@ -314,7 +314,7 @@ private function GetDefinition(): array $dependsOn, $secrets, $devices, - $nvidia, + $enable_gpu, $capAdd, $shmSize, $apparmorUnconfined, diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 31fa7272056a..c404c3e24cd1 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -968,33 +968,24 @@ public function GetEnabledCommunityContainers() : array { return explode(' ', $this->GetCommunityContainers()); } - private function GetEnabledDriDevice() : string { - $envVariableName = 'NEXTCLOUD_ENABLE_DRI_DEVICE'; - $configName = 'nextcloud_enable_dri_device'; + + private function GetEnabledGPUMode() : string { + $envVariableName = 'NEXTCLOUD_GPU_MODE'; + $configName = 'nextcloud_gpu_mode'; $defaultValue = ''; return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue); } public function isDriDeviceEnabled() : bool { - if ($this->GetEnabledDriDevice() === 'true') { - return true; - } else { - return false; - } - } - private function GetEnabledNvidiaGPUMode() : string { - $envVariableName = 'NEXTCLOUD_NVIDIA_GPU_MODE'; - $configName = 'nextcloud_nvidia_gpu_mode'; - $defaultValue = ''; - return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue); + return $this->GetEnabledGPUMode() === 'dri'; } public function isNvidiaRuntimeEnabled() : bool { - return $this->GetEnabledNvidiaGPUMode() === 'runtime'; + return $this->GetEnabledGPUMode() === 'nvidia-runtime'; } public function isNvidiaDeployEnabled() : bool { - return $this->GetEnabledNvidiaGPUMode() === 'deploy'; + return $this->GetEnabledGPUMode() === 'nvidia-deploy'; } private function GetKeepDisabledApps() : string { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 1ca27a01ff5f..b19a95dbb652 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -481,18 +481,13 @@ public function CreateContainer(Container $container) : void { $devices = []; foreach($container->GetDevices() as $device) { - if ($device === '/dev/dri' && ! $this->configurationManager->isDriDeviceEnabled()) { - continue; - } $devices[] = ["PathOnHost" => $device, "PathInContainer" => $device, "CgroupPermissions" => "rwm"]; } - if (count($devices) > 0) { - $requestBody['HostConfig']['Devices'] = $devices; - } - if ($container->canUseNvidia()) { - if ($this->configurationManager->isNvidiaRuntimeEnabled()) { + if($this->configurationManager->isDriDeviceEnabled()) { + $devices[] = ["PathOnHost" => '/dev/dri', "PathInContainer" => '/dev/dri', "CgroupPermissions" => "rwm"]; + } elseif ($this->configurationManager->isNvidiaRuntimeEnabled()) { $requestBody['HostConfig']['Runtime'] = 'nvidia'; } elseif ($this->configurationManager->isNvidiaDeployEnabled()) { $requestBody['HostConfig']['DeviceRequests'] = [ @@ -505,6 +500,10 @@ public function CreateContainer(Container $container) : void { } } + if (count($devices) > 0) { + $requestBody['HostConfig']['Devices'] = $devices; + } + $shmSize = $container->GetShmSize(); if ($shmSize > 0) { $requestBody['HostConfig']['ShmSize'] = $shmSize; diff --git a/php/templates/includes/aio-config.twig b/php/templates/includes/aio-config.twig index f4f2741771bf..dce902021a9f 100644 --- a/php/templates/includes/aio-config.twig +++ b/php/templates/includes/aio-config.twig @@ -30,21 +30,15 @@

{% if is_dri_device_enabled == true %} - The /dev/dri device which is needed for hardware transcoding is getting attached to the Nextcloud container. - {% else %} - The /dev/dri device which is needed for hardware transcoding is not attached to the Nextcloud container. - {% endif %} - See the NEXTCLOUD_ENABLE_DRI_DEVICE documentation on how to change this.

- -

- {% if is_nvidia_runtime_enabled == true %} - Nvidia runtime is enabled. + The /dev/dri device is getting attached to the Nextcloud container. + {% elseif is_nvidia_runtime_enabled == true %} + The Nvida runtime is used for the Nextcloud container. {% elseif is_nvidia_gpu_deploy_enabled == true %} - Nvidia GPU access is enabled. + The Nvidia device is getting attached to the Nextcloud container. {% else %} - Nvidia GPU access is disabled. + No GPU acceleration is enabled. It's recommended to enable hardware transcoding for better performance. {% endif %} -

+ See the NEXTCLOUD_GPU_MODE documentation on how to change this.

For further documentation on AIO, refer to this page. You can use the browser search [CTRL]+[F] to search through the documentation. Additional documentation can be found here.

diff --git a/readme.md b/readme.md index 38016ce20db5..914016c2f38c 100644 --- a/readme.md +++ b/readme.md @@ -765,11 +765,33 @@ You can do so by adding `--env NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS="imagick exte ### What about the pdlib PHP extension for the facerecognition app? The [facerecognition app](https://apps.nextcloud.com/apps/facerecognition) requires the pdlib PHP extension to be installed. Unfortunately, it is not available on PECL nor via PHP core, so there is no way to add this into AIO currently. However you can use [this community container](https://github.com/nextcloud/all-in-one/tree/main/community-containers/facerecognition) in order to run facerecognition. -### How to enable hardware-transcoding for Nextcloud? +### How to enable GPU acceleration for Nextcloud? +Some container can use GPU acceleration to increase performance like [memories app](https://apps.nextcloud.com/apps/memories) allows to enable hardware transcoding for videos. + +To enable it you need to add `--env NEXTCLOUD_GPU_MODE=` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used). + +#### With open source drivers MESA for AMD, Intel and **new** drivers `Nouveau` for Nvidia + > [!WARNING] -> This only works if the `/dev/dri` device is present on the host! If it does not exists on your host, don't proceed as otherwise the Nextcloud container will fail to start! If you are unsure about this, better do not proceed with the instructions below. +> This only works if the `/dev/dri` device is present on the host! If it does not exists on your host, don't proceed as otherwise the Nextcloud container will fail to start! If you are unsure about this, better do not proceed with the instructions below. Make sure that your driver is correctly configured on the host. + +A list of supported device can be fond in [MESA 3D documentation](https://docs.mesa3d.org/systems.html). + +This methode use the [Direct Rendering Infrastructure](https://dri.freedesktop.org/wiki/) with the access to the `/dev/dri` device. + +To enable it, use `--env NEXTCLOUD_GPU_MODE=dri` as driver mode. + +#### With proprietary drivers for Nvidia :warning: BETA + +> [!WARNING] +> This feature is in beta. Since the proprietary, we haven't a lot of user using proprietary drivers, we can't guarantee the stability of this feature. +> Your feedback is welcome. + +This methode use the [Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html) with the nvidia runtime. + +To enable it, use `--env NEXTCLOUD_GPU_MODE=nvidia-runtime` as driver mode. -The [memories app](https://apps.nextcloud.com/apps/memories) allows to enable hardware transcoding for videos. In order to use that, you need to add `--env NEXTCLOUD_ENABLE_DRI_DEVICE=true` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used) which will mount the `/dev/dri` device into the container. There is now a community container which allows to easily add the transcoding container of Memories to AIO: https://github.com/nextcloud/all-in-one/tree/main/community-containers/memories +You can use docker resource allocation with `--env NEXTCLOUD_GPU_MODE=nvidia-deploy` as driver mode. ### How to keep disabled apps? In certain situations you might want to keep Nextcloud apps that are disabled in the AIO interface and not uninstall them if they should be installed in Nextcloud. You can do so by adding `--env NEXTCLOUD_KEEP_DISABLED_APPS=true` to the docker run command of the mastercontainer (but before the last line `nextcloud/all-in-one:latest`! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used). diff --git a/tests/QA/060-environmental-variables.md b/tests/QA/060-environmental-variables.md index 5113bdf7601c..d156bb404bbf 100644 --- a/tests/QA/060-environmental-variables.md +++ b/tests/QA/060-environmental-variables.md @@ -1,5 +1,7 @@ # Environmental variables +[//]: # (TODO NEXTCLOUD_GPU_MODE) + - [ ] When starting the mastercontainer with `--env APACHE_PORT=11000` on a clean instance, the domaincheck container should be started with that same port published. That makes sure that also the Apache container will use that port later on. Using a value here that is not a port will not allow the mastercontainer to start correctly. However `@INTERNAL` is also an allowed value which skips publishing the port on the host for internal usage inside a bridged network for example. - [ ] When starting the mastercontainer with `--env APACHE_IP_BINDING=127.0.0.1` on a clean instance, the domaincheck container's apache port should only listen on localhost on the host. Using a value here that is not a number or dot will not allow the mastercontainer to start correctly. - [ ] When starting the mastercontainer with `--env APACHE_ADDITIONAL_NETWORK=frontend_net` on a clean instance, the domaincheck and subsequently the apache containers should be connected to the specified `frontend_net` docker network, in addition to the default `nextcloud-aio` network. Specifying the network that doesn't already exist will not allow the mastercontainer to start correctly.