From 09d78bb6b9e8b173f44f5ba3abaee0de416b0ee0 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 21 Jun 2021 23:49:43 -0400 Subject: [PATCH] allow multi gpu to be specified via ctr Signed-off-by: Michael Crosby --- cmd/ctr/commands/commands.go | 2 +- cmd/ctr/commands/run/run_unix.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/ctr/commands/commands.go b/cmd/ctr/commands/commands.go index 5a58e9a33..8344111d4 100644 --- a/cmd/ctr/commands/commands.go +++ b/cmd/ctr/commands/commands.go @@ -147,7 +147,7 @@ var ( Name: "pid-file", Usage: "file path to write the task's pid", }, - cli.IntFlag{ + cli.IntSliceFlag{ Name: "gpus", Usage: "add gpus to the container", }, diff --git a/cmd/ctr/commands/run/run_unix.go b/cmd/ctr/commands/run/run_unix.go index cb5abd876..5c5fee3db 100644 --- a/cmd/ctr/commands/run/run_unix.go +++ b/cmd/ctr/commands/run/run_unix.go @@ -250,7 +250,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli })) } if context.IsSet("gpus") { - opts = append(opts, nvidia.WithGPUs(nvidia.WithDevices(context.Int("gpus")), nvidia.WithAllCapabilities)) + opts = append(opts, nvidia.WithGPUs(nvidia.WithDevices(context.IntSlice("gpus")...), nvidia.WithAllCapabilities)) } if context.IsSet("allow-new-privs") { opts = append(opts, oci.WithNewPrivileges)