diff -upNr mesos-1.8.1-vanilla/3rdparty/Makefile.am mesos-1.8.1/3rdparty/Makefile.am
--- mesos-1.8.1-vanilla/3rdparty/Makefile.am 2019-09-25 08:06:05.908901260 +0200
+++ mesos-1.8.1/3rdparty/Makefile.am 2019-09-25 08:09:10.844387596 +0200
@@ -381,10 +381,12 @@ $(LIBSECCOMP)-build-stamp: $(LIBSECCOMP)
ALL_LOCAL += $(LIB_LIBSECCOMP)
endif
+if ENABLE_USE_NVML
if WITH_BUNDLED_NVML
$(NVML)/nvidia/gdk/nvml.h: $(NVML)-stamp
ALL_LOCAL += $(NVML)-stamp
endif
+endif
if WITH_BUNDLED_PICOJSON
# Stout depends on <picojson.h>. Install picojson.h into $PREFIX/include
diff -upNr mesos-1.8.1-vanilla/configure.ac mesos-1.8.1/configure.ac
--- mesos-1.8.1-vanilla/configure.ac 2019-09-25 08:06:05.909901274 +0200
+++ mesos-1.8.1/configure.ac 2019-09-25 09:53:08.194845648 +0200
@@ -268,6 +268,11 @@ AC_ARG_ENABLE([java],
[do not build Java bindings]),
[], [enable_java=yes])
+AC_ARG_ENABLE([use-nvml],
+ AS_HELP_STRING([--disable-use-nvml],
+ [do not use the NVML headers]),
+ [], [enable_use_nvml=yes])
+
# TODO(bevers): Eventually make this enabled by default.
AC_ARG_ENABLE([jemalloc-allocator],
AS_HELP_STRING([--enable-jemalloc-allocator],
@@ -1717,30 +1722,37 @@ AM_CONDITIONAL(
[ENABLE_LINUX_ROUTING],
[test "x$enable_network_ports_isolator" = "xyes" -o "x$enable_port_mapping_isolator" = "xyes"])
+AM_CONDITIONAL(
+ [ENABLE_USE_NVML],
+ [test "x$enable_use_nvml" = "xyes"])
+
+AM_COND_IF([ENABLE_USE_NVML], [AC_DEFINE([ENABLE_USE_NVML])])
# If the user has asked not to include the bundled NVML headers for
# Nvidia GPU support, check to see if the path to the NVML headers has
# been specified. If it has, make sure that the path is absolute. If
# everything is in order, add this path to the CPPFLAGS.
-if test "x$without_bundled_nvml" = "xyes" || \
- test "x$enable_bundled" != "xyes"; then
- if test -n "`echo $with_nvml`"; then
- if test "$with_nvml" = "${with_nvml#/}"; then
- AC_MSG_ERROR([The path passed to --with-nvml must be absolute.])
- fi
- CPPFLAGS="-I${with_nvml} $CPPFLAGS"
- fi
+if test "x$enable_use_nvml" = "xyes"; then
+ if test "x$without_bundled_nvml" = "xyes" || \
+ test "x$enable_bundled" != "xyes"; then
+ if test -n "`echo $with_nvml`"; then
+ if test "$with_nvml" = "${with_nvml#/}"; then
+ AC_MSG_ERROR([The path passed to --with-nvml must be absolute.])
+ fi
+ CPPFLAGS="-I${with_nvml} $CPPFLAGS"
+ fi
- AC_CHECK_HEADERS([nvidia/gdk/nvml.h], [],
+ AC_CHECK_HEADERS([nvidia/gdk/nvml.h], [],
[AC_MSG_ERROR([Cannot find the Nvidia NVML headers
--------------------------------------------------------------------
-You have requested the use of a non-bundled NVML but no suitable
-NVML headers could be found. Make sure these headers are either
-installed on the system or the path passed via --with-nvml is correct.
--------------------------------------------------------------------
- ])])
-else
- with_bundled_nvml=yes
+ -------------------------------------------------------------------
+ You have requested the use of a non-bundled NVML but no suitable
+ NVML headers could be found. Make sure these headers are either
+ installed on the system or the path passed via --with-nvml is correct.
+ -------------------------------------------------------------------
+ ])])
+ else
+ with_bundled_nvml=yes
+ fi
fi
AM_CONDITIONAL([WITH_BUNDLED_NVML],
diff -upNr mesos-1.8.1-vanilla/src/Makefile.am mesos-1.8.1/src/Makefile.am
--- mesos-1.8.1-vanilla/src/Makefile.am 2019-07-10 18:31:21.066015412 +0200
+++ mesos-1.8.1/src/Makefile.am 2019-09-25 09:27:32.364725665 +0200
@@ -239,8 +239,10 @@ LIB_LIBSECCOMP = -lseccomp
endif
endif
-if WITH_BUNDLED_NVML
-MESOS_CPPFLAGS += -I../$(NVML)
+if ENABLE_USE_NVML
+ if WITH_BUNDLED_NVML
+ MESOS_CPPFLAGS += -I../$(NVML)
+ endif
endif
if WITH_BUNDLED_PICOJSON
diff -upNr mesos-1.8.1-vanilla/src/slave/containerizer/mesos/containerizer.cpp mesos-1.8.1/src/slave/containerizer/mesos/containerizer.cpp
--- mesos-1.8.1-vanilla/src/slave/containerizer/mesos/containerizer.cpp 2019-07-10 18:31:21.106015928 +0200
+++ mesos-1.8.1/src/slave/containerizer/mesos/containerizer.cpp 2019-09-25 09:28:53.277789662 +0200
@@ -103,7 +103,6 @@
#include "slave/containerizer/mesos/isolators/docker/volume/isolator.hpp"
#include "slave/containerizer/mesos/isolators/filesystem/linux.hpp"
#include "slave/containerizer/mesos/isolators/filesystem/shared.hpp"
-#include "slave/containerizer/mesos/isolators/gpu/nvidia.hpp"
#include "slave/containerizer/mesos/isolators/linux/capabilities.hpp"
#include "slave/containerizer/mesos/isolators/linux/devices.hpp"
#include "slave/containerizer/mesos/isolators/namespaces/ipc.hpp"
diff -upNr mesos-1.8.1-vanilla/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp mesos-1.8.1/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp
--- mesos-1.8.1-vanilla/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp 2019-07-10 18:31:21.110015979 +0200
+++ mesos-1.8.1/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp 2019-09-25 09:31:45.561055131 +0200
@@ -18,8 +18,6 @@
#include <glog/logging.h>
-#include <nvidia/gdk/nvml.h>
-
#include <map>
#include <string>
@@ -38,6 +36,14 @@
#include "slave/containerizer/mesos/isolators/gpu/nvml.hpp"
+#ifndef ENABLE_USE_NVML
+ // We provide dummy types and variables in case we do not use the NVML headers.
+using nvmlReturn_t = int;
+constexpr bool NVML_SUCCESS = true;
+constexpr size_t NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE = 1;
+constexpr nvmlReturn_t NVML_ERROR_INVALID_ARGUMENT{};
+#endif // ENABLE_USE_NVML
+
using process::Once;
using std::map;
@@ -153,6 +159,10 @@ Try<Nothing> initialize()
bool isAvailable()
{
+#ifndef ENABLE_USE_NVML
+ return false;
+#endif // ENABLE_USE_NVML
+
// Unfortunately, there is no function available in `glibc` to check
// if a dynamic library is available to open with `dlopen()`.
// Instead, availability is determined by attempting to open a
diff -upNr mesos-1.8.1-vanilla/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp mesos-1.8.1/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp
--- mesos-1.8.1-vanilla/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp 2019-07-10 18:31:21.110015979 +0200
+++ mesos-1.8.1/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp 2019-09-25 09:30:02.536700392 +0200
@@ -17,7 +17,12 @@
#ifndef __NVIDIA_NVML_HPP__
#define __NVIDIA_NVML_HPP__
-#include <nvidia/gdk/nvml.h>
+#ifdef ENABLE_USE_NVML
+ #include <nvidia/gdk/nvml.h>
+#else
+ // We provide dummy types in case we do not use the NVML headers.
+ using nvmlDevice_t = int;
+#endif // ENABLE_USE_NVML
#include <string>
diff -upNr mesos-1.8.1-vanilla/src/tests/environment.cpp mesos-1.8.1/src/tests/environment.cpp
--- mesos-1.8.1-vanilla/src/tests/environment.cpp 2019-07-10 18:31:21.134016289 +0200
+++ mesos-1.8.1/src/tests/environment.cpp 2019-09-25 09:34:03.386867517 +0200
@@ -259,7 +259,19 @@ class NvidiaGpuFilter : public TestFilte
public:
NvidiaGpuFilter()
{
+#ifndef ENABLE_USE_NVML
+ nvidiaGpuError = true;
+
+ std::cerr
+ << "-------------------------------------------------------------\n"
+ << "Linking against libnvml is disabled so\n"
+ << " no Nvidia GPU tests will be run\n"
+ << "-------------------------------------------------------------"
+ << std::endl;
+#else
+
nvidiaGpuError = os::which("nvidia-smi").isNone();
+
if (nvidiaGpuError) {
std::cerr
<< "-------------------------------------------------------------\n"
@@ -267,6 +279,7 @@ public:
<< "-------------------------------------------------------------"
<< std::endl;
}
+#endif // ENABLE_USE_NVML
}
bool disable(const ::testing::TestInfo* test) const override