This is an automated email from the ASF dual-hosted git repository.
bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
The following commit(s) were added to refs/heads/master by this push:
new 8935576 Allowed disabling use of NVML headers.
8935576 is described below
commit 89355768a403b0899154eaaedf077c1c20d75938
Author: Benjamin Bannier <[email protected]>
AuthorDate: Tue Jan 7 13:33:01 2020 +0100
Allowed disabling use of NVML headers.
NVML is distributed under a license which is probably not "free" which
can e.g., be aan obstacle when including Mesos using symbols from it in
certain distributions.
This patch adds a configure flag to disable use of the NVML headers
completely. Note that with this flag disabled it is impossible to use
GPU isolation with the Mesos containerizer.
Review: https://reviews.apache.org/r/71538/
---
3rdparty/CMakeLists.txt | 32 +++++-----
3rdparty/Makefile.am | 2 +
cmake/CompilationConfigure.cmake | 5 ++
configure.ac | 69 +++++++++++++---------
docs/configuration/autotools.md | 14 ++++-
docs/configuration/cmake.md | 8 +++
src/CMakeLists.txt | 3 +-
src/Makefile.am | 2 +
src/slave/containerizer/mesos/containerizer.cpp | 1 -
.../containerizer/mesos/isolators/gpu/nvml.cpp | 14 ++++-
.../containerizer/mesos/isolators/gpu/nvml.hpp | 5 ++
src/tests/environment.cpp | 12 ++++
12 files changed, 117 insertions(+), 50 deletions(-)
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 23ef7c1..c45d742 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -489,22 +489,24 @@ ExternalProject_Add(
URL_HASH ${RAPIDJSON_HASH})
-# NVML: NVIDIA Management Library.
-# https://developer.nvidia.com/nvidia-management-library-nvml
-#############################################################
-EXTERNAL(nvml ${NVML_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
-add_library(nvml INTERFACE)
-add_dependencies(nvml ${NVML_TARGET})
-target_include_directories(nvml INTERFACE ${NVML_ROOT})
+if (ENABLE_NVML)
+ # NVML: NVIDIA Management Library.
+ # https://developer.nvidia.com/nvidia-management-library-nvml
+ #############################################################
+ EXTERNAL(nvml ${NVML_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
+ add_library(nvml INTERFACE)
+ add_dependencies(nvml ${NVML_TARGET})
+ target_include_directories(nvml INTERFACE ${NVML_ROOT})
-ExternalProject_Add(
- ${NVML_TARGET}
- PREFIX ${NVML_CMAKE_ROOT}
- CONFIGURE_COMMAND ${CMAKE_NOOP}
- BUILD_COMMAND ${CMAKE_NOOP}
- INSTALL_COMMAND ${CMAKE_NOOP}
- URL ${NVML_URL}
- URL_HASH ${NVML_HASH})
+ ExternalProject_Add(
+ ${NVML_TARGET}
+ PREFIX ${NVML_CMAKE_ROOT}
+ CONFIGURE_COMMAND ${CMAKE_NOOP}
+ BUILD_COMMAND ${CMAKE_NOOP}
+ INSTALL_COMMAND ${CMAKE_NOOP}
+ URL ${NVML_URL}
+ URL_HASH ${NVML_HASH})
+endif ()
# HTTP Parser: HTTP request/response parser for C.
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index 0de005d..243a619 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -387,10 +387,12 @@ $(LIBSECCOMP)-build-stamp: $(LIBSECCOMP)-stamp
ALL_LOCAL += $(LIB_LIBSECCOMP)
endif
+if ENABLE_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 --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index 089df91..f9511fc 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -148,6 +148,11 @@ option(
FALSE)
option(
+ ENABLE_NVML
+ "Whether to use the NVML headers."
+ TRUE)
+
+option(
PYTHON
"Command for the Python interpreter, set to `python` if not given."
"python")
diff --git a/configure.ac b/configure.ac
index 2bf3a34..4aa4f76 100644
--- a/configure.ac
+++ b/configure.ac
@@ -268,6 +268,11 @@ AC_ARG_ENABLE([java],
[do not build Java bindings]),
[], [enable_java=yes])
+AC_ARG_ENABLE([nvml],
+ AS_HELP_STRING([--disable-nvml],
+ [do not use the NVML headers]),
+ [], [enable_nvml=yes])
+
# TODO(bevers): Eventually make this enabled by default.
AC_ARG_ENABLE([jemalloc-allocator],
AS_HELP_STRING([--enable-jemalloc-allocator],
@@ -1385,10 +1390,10 @@ __EOF__
dir="$JAVA_HOME/jre/lib/server"
for dir in "$JAVA_HOME/lib/server" "$JAVA_HOME/jre/lib/server"; do
if test -e "$dir"; then
- # Note that these are libtool specific flags.
+ # Note that these are libtool specific flags.
JAVA_TEST_LDFLAGS="-framework JavaVM"
JAVA_JVM_LIBRARY=$dir/libjvm.dylib
- break;
+ break;
fi
done
elif test "$OS_NAME" = "linux"; then
@@ -1397,20 +1402,20 @@ __EOF__
"$JAVA_HOME/jre/lib/"{amd64,i386,arm,aarch64,ppc64,ppc64le,s390,s390x}"/server"
do
if test -e "$dir"; then
- # Note that these are libtool specific flags.
- JAVA_TEST_LDFLAGS="-L$dir -R$dir -Wl,-ljvm"
- JAVA_JVM_LIBRARY=$dir/libjvm.so
- break;
+ # Note that these are libtool specific flags.
+ JAVA_TEST_LDFLAGS="-L$dir -R$dir -Wl,-ljvm"
+ JAVA_JVM_LIBRARY=$dir/libjvm.so
+ break;
fi
done
elif test "$OS_NAME" = "freebsd"; then
for arch in amd64 i386 arm; do
dir="$JAVA_HOME/jre/lib/$arch/server"
if test -e "$dir"; then
- # Note that these are libtool specific flags.
- JAVA_TEST_LDFLAGS="-L$dir -R$dir -pthread -Wl,-ljvm"
- JAVA_JVM_LIBRARY=$dir/libjvm.so
- break;
+ # Note that these are libtool specific flags.
+ JAVA_TEST_LDFLAGS="-L$dir -R$dir -pthread -Wl,-ljvm"
+ JAVA_JVM_LIBRARY=$dir/libjvm.so
+ break;
fi
done
fi
@@ -1783,29 +1788,37 @@ AM_CONDITIONAL(
[test "x$enable_network_ports_isolator" = "xyes" -o
"x$enable_port_mapping_isolator" = "xyes"])
+AM_CONDITIONAL(
+ [ENABLE_NVML],
+ [test "x$enable_nvml" = "xyes"])
+
+AM_COND_IF([ENABLE_NVML], [AC_DEFINE([ENABLE_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.])
+if test "x$enable_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
- CPPFLAGS="-I${with_nvml} $CPPFLAGS"
- fi
- 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
+ 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
+ fi
fi
AM_CONDITIONAL([WITH_BUNDLED_NVML],
@@ -2682,7 +2695,7 @@ There are two possible workarounds for this issue:
PYTHON_LDFLAGS="$LDFLAGS $GFLAGS_LIBS"
AS_IF([test "x$ax_cv_cxx_compiler_vendor" = "xclang"],
- [PYTHON_CPPFLAGS="$PYTHON_CPPFLAGS -Qunused-arguments"
+ [PYTHON_CPPFLAGS="$PYTHON_CPPFLAGS -Qunused-arguments"
PYTHON_CFLAGS="$PYTHON_CFLAGS -Qunused-arguments"])
AC_SUBST([PYTHON_CPPFLAGS])
diff --git a/docs/configuration/autotools.md b/docs/configuration/autotools.md
index 577e794..887f294 100644
--- a/docs/configuration/autotools.md
+++ b/docs/configuration/autotools.md
@@ -149,6 +149,15 @@ layout: documentation
</tr>
<tr>
<td>
+ --enable-install-module-dependencies
+ </td>
+ <td>
+ Install third-party bundled dependencies required for module development.
+ [default=no]
+ </td>
+ </tr>
+ <tr>
+ <td>
--disable-java
</td>
<td>
@@ -167,11 +176,10 @@ layout: documentation
</tr>
<tr>
<td>
- --enable-install-module-dependencies
+ --disable-use-nvml
</td>
+ Disable use of the NVML headers.
<td>
- Install third-party bundled dependencies required for module development.
- [default=no]
</td>
</tr>
<tr>
diff --git a/docs/configuration/cmake.md b/docs/configuration/cmake.md
index 554c3bf..35a017c 100644
--- a/docs/configuration/cmake.md
+++ b/docs/configuration/cmake.md
@@ -202,4 +202,12 @@ See more information in the [CMake
documentation](../cmake.md).
Windows</a> binary. [default=%PROGRAMFILESX86%/GnuWin32/bin/patch.exe]
</td>
</tr>
+ <tr>
+ <td>
+ -DENABLE_NVML=(TRUE|FALSE)
+ </td>
+ <td>
+ Enable use of the NVML headers. [default=TRUE]
+ </td>
+ </tr>
</table>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0c97e3e..5133550 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -609,6 +609,7 @@ target_compile_definitions(
USE_CMAKE_BUILD_CONFIG
$<$<BOOL:${ENABLE_XFS_DISK_ISOLATOR}>:ENABLE_XFS_DISK_ISOLATOR>
$<$<BOOL:${ENABLE_LAUNCHER_SEALING}>:ENABLE_LAUNCHER_SEALING>
+ $<$<BOOL:${ENABLE_NVML}>:ENABLE_NVML>
$<$<BOOL:${ENABLE_PORT_MAPPING_ISOLATOR}>:ENABLE_PORT_MAPPING_ISOLATOR>
$<$<BOOL:${ENABLE_NETWORK_PORTS_ISOLATOR}>:ENABLE_NETWORK_PORTS_ISOLATOR>
$<$<BOOL:${ENABLE_SECCOMP_ISOLATOR}>:ENABLE_SECCOMP_ISOLATOR>)
@@ -626,7 +627,7 @@ target_link_libraries(
sasl2
zookeeper
mesos-protobufs
- $<$<PLATFORM_ID:Linux>:nvml>
+ $<$<AND:$<PLATFORM_ID:Linux>,$<BOOL:${ENABLE_NVML}>>:nvml>
$<$<BOOL:${HAS_JAVA}>:mesos-java>)
if (NOT WIN32)
diff --git a/src/Makefile.am b/src/Makefile.am
index 45c107c..22506f2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -239,9 +239,11 @@ LIB_LIBSECCOMP = -lseccomp
endif
endif
+if ENABLE_NVML
if WITH_BUNDLED_NVML
MESOS_CPPFLAGS += -I../$(NVML)
endif
+endif
if WITH_BUNDLED_PICOJSON
MESOS_CPPFLAGS += -I../$(PICOJSON)
diff --git a/src/slave/containerizer/mesos/containerizer.cpp
b/src/slave/containerizer/mesos/containerizer.cpp
index dd94016..d034c02 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -105,7 +105,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/linux/nnp.hpp"
diff --git a/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp
b/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp
index 48a5bf6..2fddf4d 100644
--- a/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp
+++ b/src/slave/containerizer/mesos/isolators/gpu/nvml.cpp
@@ -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_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_NVML
+
using process::Once;
using std::map;
@@ -153,6 +159,10 @@ Try<Nothing> initialize()
bool isAvailable()
{
+#ifndef ENABLE_NVML
+ return false;
+#endif // ENABLE_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 --git a/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp
b/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp
index eb5c0b0..12b01aa 100644
--- a/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp
+++ b/src/slave/containerizer/mesos/isolators/gpu/nvml.hpp
@@ -17,7 +17,12 @@
#ifndef __NVIDIA_NVML_HPP__
#define __NVIDIA_NVML_HPP__
+#ifdef ENABLE_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_NVML
#include <string>
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index c3596fb..b9cfe57 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -259,7 +259,18 @@ class NvidiaGpuFilter : public TestFilter
public:
NvidiaGpuFilter()
{
+#ifndef ENABLE_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 +278,7 @@ public:
<< "-------------------------------------------------------------"
<< std::endl;
}
+#endif // ENABLE_NVML
}
bool disable(const ::testing::TestInfo* test) const override