[lxc-devel] [lxd/master] gpu: special case passing all GPUs
brauner on Github
lxc-bot at linuxcontainers.org
Fri Jun 22 15:56:56 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180622/e3f28a9b/attachment.bin>
-------------- next part --------------
From fe5ad0eb92b4403ff99c17bafc2955d3eb863059 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 22 Jun 2018 17:55:31 +0200
Subject: [PATCH] gpu: special case passing all GPUs
Closes #4683.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/container_lxc.go | 6 +++---
lxd/devices.go | 9 +++++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 6002f4e48..44430011b 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2082,7 +2082,7 @@ func (c *containerLXC) startCommon() (string, error) {
}
} else if m["type"] == "gpu" {
if gpus == nil {
- gpus, nvidiaDevices, err = deviceLoadGpu()
+ gpus, nvidiaDevices, err = deviceLoadGpu(len(m) == 0)
if err != nil {
return "", err
}
@@ -4325,7 +4325,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
}
} else if m["type"] == "gpu" {
if gpus == nil {
- gpus, nvidiaDevices, err = deviceLoadGpu()
+ gpus, nvidiaDevices, err = deviceLoadGpu(len(m) == 0)
if err != nil {
return err
}
@@ -4449,7 +4449,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
}
} else if m["type"] == "gpu" {
if gpus == nil {
- gpus, nvidiaDevices, err = deviceLoadGpu()
+ gpus, nvidiaDevices, err = deviceLoadGpu(len(m) == 0)
if err != nil {
return err
}
diff --git a/lxd/devices.go b/lxd/devices.go
index 2a816357b..521d424fe 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -169,7 +169,7 @@ func findNvidiaMinor(pci string) (string, error) {
return "", err
}
-func deviceLoadGpu() ([]gpuDevice, []nvidiaGpuDevices, error) {
+func deviceLoadGpu(all bool) ([]gpuDevice, []nvidiaGpuDevices, error) {
const DRI_PATH = "/sys/bus/pci/devices"
var gpus []gpuDevice
var nvidiaDevices []nvidiaGpuDevices
@@ -270,7 +270,12 @@ func deviceLoadGpu() ([]gpuDevice, []nvidiaGpuDevices, error) {
minor, err := findNvidiaMinor(tmpGpu.pci)
if err != nil {
- if os.IsNotExist(err) {
+ // If all devices are supposed to be
+ // passed we can ignore errors here.
+ // The function will collect all
+ // additional nvidia devices below
+ // anyway.
+ if os.IsNotExist(err) || all {
continue
}
return nil, nil, err
More information about the lxc-devel
mailing list