mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-19 22:16:49 +00:00
add support for nvidia gpu access (#5132)
Signed-off-by: Mondo <mondo.jiang@wisc.edu> Signed-off-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Signed-off-by: Simon L. <szaimen@e.mail.de> Co-authored-by: Jean-Yves <7360784+docjyJ@users.noreply.github.com> Co-authored-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
parent
119d03694e
commit
53edc5d4a9
17 changed files with 92 additions and 11 deletions
|
|
@ -160,6 +160,9 @@
|
|||
"pattern": "^/dev/[a-z]+$"
|
||||
}
|
||||
},
|
||||
"enable_nvidia_gpu": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"apparmor_unconfined": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -263,6 +263,7 @@
|
|||
"devices": [
|
||||
"/dev/dri"
|
||||
],
|
||||
"enable_nvidia_gpu": true,
|
||||
"backup_volumes": [
|
||||
"nextcloud_aio_nextcloud"
|
||||
],
|
||||
|
|
@ -520,6 +521,10 @@
|
|||
"profiles": [
|
||||
"talk-recording"
|
||||
],
|
||||
"devices": [
|
||||
"/dev/dri"
|
||||
],
|
||||
"enable_nvidia_gpu": true,
|
||||
"networks": [
|
||||
"nextcloud-aio"
|
||||
],
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ $app->get('/containers', function (Request $request, Response $response, array $
|
|||
'nextcloud_max_time' => $configurationManager->GetNextcloudMaxTime(),
|
||||
'nextcloud_memory_limit' => $configurationManager->GetNextcloudMemoryLimit(),
|
||||
'is_dri_device_enabled' => $configurationManager->isDriDeviceEnabled(),
|
||||
'is_nvidia_gpu_enabled' => $configurationManager->isNvidiaGpuEnabled(),
|
||||
'is_talk_recording_enabled' => $configurationManager->isTalkRecordingEnabled(),
|
||||
'is_docker_socket_proxy_enabled' => $configurationManager->isDockerSocketProxyEnabled(),
|
||||
'is_whiteboard_enabled' => $configurationManager->isWhiteboardEnabled(),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ readonly class Container {
|
|||
private array $secrets,
|
||||
/** @var string[] */
|
||||
private array $devices,
|
||||
private bool $enable_nvidia_gpu,
|
||||
/** @var string[] */
|
||||
private array $capAdd,
|
||||
private int $shmSize,
|
||||
|
|
@ -92,6 +93,10 @@ readonly class Container {
|
|||
return $this->devices;
|
||||
}
|
||||
|
||||
public function isNvidiaGpuEnabled() : bool {
|
||||
return $this->enable_nvidia_gpu;
|
||||
}
|
||||
|
||||
public function GetCapAdds() : array {
|
||||
return $this->capAdd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,6 +249,11 @@ readonly class ContainerDefinitionFetcher {
|
|||
$devices = $entry['devices'];
|
||||
}
|
||||
|
||||
$enableNvidiaGpu = false;
|
||||
if (is_bool($entry['enable_nvidia_gpu'])) {
|
||||
$enableNvidiaGpu = $entry['enable_nvidia_gpu'];
|
||||
}
|
||||
|
||||
$capAdd = [];
|
||||
if (isset($entry['cap_add'])) {
|
||||
$capAdd = $entry['cap_add'];
|
||||
|
|
@ -312,6 +317,7 @@ readonly class ContainerDefinitionFetcher {
|
|||
$dependsOn,
|
||||
$secrets,
|
||||
$devices,
|
||||
$enableNvidiaGpu,
|
||||
$capAdd,
|
||||
$shmSize,
|
||||
$apparmorUnconfined,
|
||||
|
|
|
|||
|
|
@ -983,6 +983,17 @@ class ConfigurationManager
|
|||
}
|
||||
}
|
||||
|
||||
private function GetEnabledNvidiaGpu() : string {
|
||||
$envVariableName = 'ENABLE_NVIDIA_GPU';
|
||||
$configName = 'enable_nvidia_gpu';
|
||||
$defaultValue = '';
|
||||
return $this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue);
|
||||
}
|
||||
|
||||
public function isNvidiaGpuEnabled() : bool {
|
||||
return $this->GetEnabledNvidiaGpu() === 'true';
|
||||
}
|
||||
|
||||
private function GetKeepDisabledApps() : string {
|
||||
$envVariableName = 'NEXTCLOUD_KEEP_DISABLED_APPS';
|
||||
$configName = 'nextcloud_keep_disabled_apps';
|
||||
|
|
|
|||
|
|
@ -491,6 +491,17 @@ readonly class DockerActionManager {
|
|||
$requestBody['HostConfig']['Devices'] = $devices;
|
||||
}
|
||||
|
||||
if ($container->isNvidiaGpuEnabled() && $this->configurationManager->isNvidiaGpuEnabled()) {
|
||||
$requestBody['HostConfig']['Runtime'] = 'nvidia';
|
||||
$requestBody['HostConfig']['DeviceRequests'] = [
|
||||
[
|
||||
"Driver" => "nvidia",
|
||||
"Count" => 1,
|
||||
"Capabilities" => [["gpu"]],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$shmSize = $container->GetShmSize();
|
||||
if ($shmSize > 0) {
|
||||
$requestBody['HostConfig']['ShmSize'] = $shmSize;
|
||||
|
|
|
|||
|
|
@ -29,12 +29,16 @@
|
|||
<p>Nextcloud has a timeout of {{ nextcloud_max_time }} seconds configured (important for big file uploads). See the <a href="https://github.com/nextcloud/all-in-one#how-to-adjust-the-max-execution-time-for-nextcloud">NEXTCLOUD_MAX_TIME documentation</a> on how to change this.</p>
|
||||
|
||||
<p>
|
||||
{% if is_dri_device_enabled == true %}
|
||||
The /dev/dri device which is needed for hardware transcoding is getting attached to the Nextcloud container.
|
||||
{% if is_dri_device_enabled == true and is_nvidia_gpu_enabled == true %}
|
||||
Hardware acceleration is enabled with the /dev/dri device and the Nvidia runtime.
|
||||
{% elseif is_dri_device_enabled == true %}
|
||||
Hardware acceleration is enabled with the /dev/dri device.
|
||||
{% elseif is_nvidia_gpu_enabled == true %}
|
||||
Hardware acceleration is enabled with the Nvidia runtime.
|
||||
{% else %}
|
||||
The /dev/dri device which is needed for hardware transcoding is not attached to the Nextcloud container.
|
||||
Hardware acceleration is not enabled. It's recommended to enable hardware transcoding for better performance.
|
||||
{% endif %}
|
||||
See the <a href="https://github.com/nextcloud/all-in-one#how-to-enable-hardware-transcoding-for-nextcloud">NEXTCLOUD_ENABLE_DRI_DEVICE documentation</a> on how to change this.</p>
|
||||
See the <a href="https://github.com/nextcloud/all-in-one#how-to-enable-hardware-acceleration-for-nextcloud">hardware acceleration documentation</a> on how to change this.</p>
|
||||
|
||||
<p>For further documentation on AIO, refer to <strong><a href="https://github.com/nextcloud/all-in-one#nextcloud-all-in-one">this page</a></strong>. You can use the browser search [CTRL]+[F] to search through the documentation. Additional documentation can be found <strong><a href="https://github.com/nextcloud/all-in-one/discussions/categories/wiki">here</a></strong>.</p>
|
||||
</details>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue