Merge pull request #5537 from hashicorp/b-nonvidia-flag

Allow compiling without nvidia integration
This commit is contained in:
Mahmood Ali
2019-04-10 13:40:55 -04:00
committed by GitHub
3 changed files with 18 additions and 4 deletions

View File

@@ -18,7 +18,6 @@ import (
multierror "github.com/hashicorp/go-multierror"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/client/taskenv"
"github.com/hashicorp/nomad/devices/gpu/nvidia"
"github.com/hashicorp/nomad/drivers/docker/docklog"
"github.com/hashicorp/nomad/drivers/shared/eventer"
nstructs "github.com/hashicorp/nomad/nomad/structs"
@@ -56,6 +55,9 @@ var (
// taskHandleVersion is the version of task handle which this driver sets
// and understands how to decode driver state
taskHandleVersion = 1
// Nvidia-container-runtime environment variable names
nvidiaVisibleDevices = "NVIDIA_VISIBLE_DEVICES"
)
type Driver struct {
@@ -684,7 +686,7 @@ func (d *Driver) createContainerConfig(task *drivers.TaskConfig, driverConfig *T
PidsLimit: driverConfig.PidsLimit,
}
if _, ok := task.DeviceEnv[nvidia.NvidiaVisibleDevices]; ok {
if _, ok := task.DeviceEnv[nvidiaVisibleDevices]; ok {
if !d.gpuRuntime {
return c, fmt.Errorf("requested docker-runtime %q was not found", d.config.GPURuntimeName)
}

View File

@@ -1,7 +1,6 @@
package catalog
import (
"github.com/hashicorp/nomad/devices/gpu/nvidia"
"github.com/hashicorp/nomad/drivers/rkt"
)
@@ -10,5 +9,4 @@ import (
// register_XXX.go file.
func init() {
RegisterDeferredConfig(rkt.PluginID, rkt.PluginConfig, rkt.PluginLoader)
Register(nvidia.PluginID, nvidia.PluginConfig)
}

View File

@@ -0,0 +1,14 @@
// +build !nonvidia
package catalog
import (
"github.com/hashicorp/nomad/devices/gpu/nvidia"
)
// This file is where all builtin plugins should be registered in the catalog.
// Plugins with build restrictions should be placed in the appropriate
// register_XXX.go file.
func init() {
Register(nvidia.PluginID, nvidia.PluginConfig)
}