From 430ba4274c2cfb20efa59c89e30bff11d5b8e012 Mon Sep 17 00:00:00 2001 From: damon Date: Sun, 29 Mar 2020 17:30:28 +1300 Subject: [PATCH] Handle "gpus" not in facts --- README.md | 14 +++++++++----- manifests/init.pp | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 56d8f71..09ab11d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # nvidia_docker_runtime This is a PDK based module https://puppet.com/pdk/latest/pdk_generating_modules.html . @@ -6,13 +5,11 @@ This is a PDK based module https://puppet.com/pdk/latest/pdk_generating_modules. #### Table of Contents 1. [Description](#description) -3. [Usage - Configuration options and additional functionality](#usage) +2. [Usage - Configuration options and additional functionality](#usage) ## Description -Modifies Docker for use with NVIDIA GPU based containers, including in swarm mode. - -## Setup +Modifies Docker for use with NVIDIA GPU based containers, including in swarm mode. ## Usage @@ -22,3 +19,10 @@ class { 'nvidia_docker_runtime': nvidia_docker2_version => '2.2.2-1', } ``` + +## Limitations + +Since GPU UUIDs are needed to specify `node-generic-resources`, and these are not available through facts until +the NVIDIA driver has been installed, it takes two applies to fully setup. Until then swarm cannot use gpu resources. + +Due to Docker limitations you can only specify gpus in compose files for compose format 2.3. As `docker stack` requires format 3.0 this means you can't use gpus in stacks. diff --git a/manifests/init.pp b/manifests/init.pp index ceae36f..1f16e74 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -66,7 +66,11 @@ } ~> Service['docker'] - $gpu_ids = $facts['gpus'].map |$gpu| { $gpu['gpu_uuid'][0,11] } + $gpu_ids = if 'gpus' in $facts { + $facts['gpus'].map |$gpu| { $gpu['gpu_uuid'][0,11] } + } else { + [] + } Package['nvidia-docker2'] -> augeas { 'daemon.json': lens => 'Json.lns',