91 lines
3.2 KiB
Diff
91 lines
3.2 KiB
Diff
From a09e3bf1a130cdc70dd07b0d5adc5ab17d0f9131 Mon Sep 17 00:00:00 2001
|
|
From: Mahmood Ali <mahmood@hashicorp.com>
|
|
Date: Wed, 10 Apr 2019 09:07:08 -0400
|
|
Subject: [PATCH] Allow compiling without nvidia integration
|
|
|
|
nvidia library use of dynamic library seems to conflict with alpine and
|
|
musl based OSes. This adds a `nonvidia` tag to allow compiling nomad
|
|
for alpine images.
|
|
|
|
The nomad releases currently only support glibc based OS environments,
|
|
so we default to compiling with nvidia.
|
|
---
|
|
drivers/docker/driver.go | 6 ++++--
|
|
helper/pluginutils/catalog/register_linux.go | 2 --
|
|
.../pluginutils/catalog/register_nvidia_linux.go | 14 ++++++++++++++
|
|
3 files changed, 18 insertions(+), 4 deletions(-)
|
|
create mode 100644 helper/pluginutils/catalog/register_nvidia_linux.go
|
|
|
|
diff --git a/drivers/docker/driver.go b/drivers/docker/driver.go
|
|
index 3403c2621..62830089b 100644
|
|
--- a/drivers/docker/driver.go
|
|
+++ b/drivers/docker/driver.go
|
|
@@ -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)
|
|
}
|
|
diff --git a/helper/pluginutils/catalog/register_linux.go b/helper/pluginutils/catalog/register_linux.go
|
|
index bb5175d11..42314cb57 100644
|
|
--- a/helper/pluginutils/catalog/register_linux.go
|
|
+++ b/helper/pluginutils/catalog/register_linux.go
|
|
@@ -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)
|
|
}
|
|
diff --git a/helper/pluginutils/catalog/register_nvidia_linux.go b/helper/pluginutils/catalog/register_nvidia_linux.go
|
|
new file mode 100644
|
|
index 000000000..a50cbe833
|
|
--- /dev/null
|
|
+++ b/helper/pluginutils/catalog/register_nvidia_linux.go
|
|
@@ -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)
|
|
+}
|
|
--
|
|
2.21.0
|
|
|