Add nvidia Opts to lookup containerd binary or hook path
This is for consumers like Docker that manage a `docker-containerd`. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
ca71484793
commit
e4f33dcfb5
@ -60,9 +60,12 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path, err := exec.LookPath("containerd")
|
if c.OCIHookPath == "" {
|
||||||
if err != nil {
|
path, err := exec.LookPath("containerd")
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.OCIHookPath = path
|
||||||
}
|
}
|
||||||
nvidiaPath, err := exec.LookPath(nvidiaCLI)
|
nvidiaPath, err := exec.LookPath(nvidiaCLI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +75,7 @@ func WithGPUs(opts ...Opts) oci.SpecOpts {
|
|||||||
s.Hooks = &specs.Hooks{}
|
s.Hooks = &specs.Hooks{}
|
||||||
}
|
}
|
||||||
s.Hooks.Prestart = append(s.Hooks.Prestart, specs.Hook{
|
s.Hooks.Prestart = append(s.Hooks.Prestart, specs.Hook{
|
||||||
Path: path,
|
Path: c.OCIHookPath,
|
||||||
Args: append([]string{
|
Args: append([]string{
|
||||||
"containerd",
|
"containerd",
|
||||||
"oci-hook",
|
"oci-hook",
|
||||||
@ -92,6 +95,7 @@ type config struct {
|
|||||||
LDCache string
|
LDCache string
|
||||||
LDConfig string
|
LDConfig string
|
||||||
Requirements []string
|
Requirements []string
|
||||||
|
OCIHookPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *config) args() []string {
|
func (c *config) args() []string {
|
||||||
@ -181,3 +185,23 @@ func WithRequiredCUDAVersion(major, minor int) Opts {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithOCIHookPath sets the hook path for the binary
|
||||||
|
func WithOCIHookPath(path string) Opts {
|
||||||
|
return func(c *config) error {
|
||||||
|
c.OCIHookPath = path
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLookupOCIHookPath sets the hook path for the binary via a binary name
|
||||||
|
func WithLookupOCIHookPath(name string) Opts {
|
||||||
|
return func(c *config) error {
|
||||||
|
path, err := exec.LookPath(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.OCIHookPath = path
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user