@@ -93,6 +93,10 @@ var ContainerFlags = []cli.Flag{
|
||||
Name: "pid-file",
|
||||
Usage: "file path to write the task's pid",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "gpus",
|
||||
Usage: "add gpus to the container",
|
||||
},
|
||||
}
|
||||
|
||||
func loadSpec(path string, s *specs.Spec) error {
|
||||
|
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/contrib/nvidia"
|
||||
"github.com/containerd/containerd/oci"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
@@ -123,6 +124,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
Path: parts[1],
|
||||
}))
|
||||
}
|
||||
if context.IsSet("gpus") {
|
||||
opts = append(opts, nvidia.WithGPUs(nvidia.WithDevices(context.Int("gpus")), nvidia.WithAllCapabilities))
|
||||
}
|
||||
if context.IsSet("config") {
|
||||
var s specs.Spec
|
||||
if err := loadSpec(context.String("config"), &s); err != nil {
|
||||
|
Reference in New Issue
Block a user