You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/06/17 19:03:44 UTC

mesos git commit: Changed build to always enable Nvidia GPU support for Linux.

Repository: mesos
Updated Branches:
  refs/heads/master 0291b46eb -> 037201178


Changed build to always enable Nvidia GPU support for Linux.

Previously, we supported a configure flag for
`--enable-nvidia-gpu-support` to explicitly enable Nvidia GPU support
when building Mesos on Linux. This commit removes this flag and
enables this support for all builds on Linux.

As part of this change, libelf now becomes a build dependence on Linux
for all build configurations. We update the docs and the docker build
scripts to accomodate this.

Review: https://reviews.apache.org/r/48832/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/03720117
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/03720117
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/03720117

Branch: refs/heads/master
Commit: 03720117839d2a5f6dcc6b2277ac1dc6e859d101
Parents: 0291b46
Author: Kevin Klues <kl...@gmail.com>
Authored: Fri Jun 17 11:40:50 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Jun 17 12:03:39 2016 -0700

----------------------------------------------------------------------
 CHANGELOG                                       |  2 +
 configure.ac                                    | 51 ++++++++------------
 docs/getting-started.md                         |  6 +--
 src/Makefile.am                                 | 30 ++++--------
 src/slave/containerizer/containerizer.cpp       |  6 +--
 src/slave/containerizer/mesos/containerizer.cpp |  4 --
 src/slave/flags.cpp                             | 22 ++++-----
 src/slave/flags.hpp                             |  4 +-
 support/docker_build.sh                         |  4 +-
 9 files changed, 49 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 0fc9f0a..aed5630 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,8 @@ This release contains the following new features:
 
   * Scheduler and Executor v1 HTTP APIs are now considered stable.
 
+  * libelf is a new build dependency on Linux, required for Nvidia GPU support.
+
   * [MESOS-4791] - **Experimental** support for v1 Master and Agent APIs. These
     APIs let operators and services (monitoring, load balancers) send HTTP
     requests to '/api/v1' endpoint on master or agent. These APIs look similar

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 101be52..3c0cfca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,11 +194,6 @@ AC_ARG_ENABLE([install-module-dependencies],
                               for module development default: no]),
               [enable_install_module_dependencies=yes], [])
 
-AC_ARG_ENABLE([nvidia-gpu-support],
-              AS_HELP_STRING([--enable-nvidia-gpu-support],
-                             [build with Nvidia GPU support default: no]),
-              [enable_nvidia_gpu_support=yes], [])
-
 AC_ARG_ENABLE([optimize],
               AS_HELP_STRING([--enable-optimize],
                              [enable optimizations. If CFLAGS/CXXFLAGS are set,
@@ -1275,11 +1270,8 @@ AM_CONDITIONAL([WITH_NETWORK_ISOLATOR],
                [test "x$with_network_isolator" = "xyes"])
 
 
-# Check if Nvidia GPU support is enabled, and if so, verify we can
-# access the NVML header files.
-if test x"$enable_nvidia_gpu_support" = "xyes"; then
-  AC_DEFINE([ENABLE_NVIDIA_GPU_SUPPORT])
-
+# Check for libelf on Linux (both headers and libraries).
+if test "$OS_NAME" = "linux"; then
   AC_CHECK_HEADERS([gelf.h], [],
                    [AC_MSG_ERROR([Cannot find the libelf headers
 -------------------------------------------------------------------
@@ -1295,37 +1287,34 @@ The libelf library is required to build Mesos with Nvidia GPU
 support. Make sure this library is installed on the system.
 -------------------------------------------------------------------
   ])])
+fi
 
-  # If the user has asked not to include the bundled NVML headers,
-  # 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"
+
+# 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
 
-    AC_CHECK_HEADERS([nvidia/gdk/nvml.h], [],
-                     [AC_MSG_ERROR([Cannot find the Nvidia NVML headers
+  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
+  ])])
+else
+  with_bundled_nvml=yes
 fi
 
-AM_CONDITIONAL([ENABLE_NVIDIA_GPU_SUPPORT],
-  [test "x$enable_nvidia_gpu_support" = "xyes"])
-
 AM_CONDITIONAL([WITH_BUNDLED_NVML],
   [test "x$with_bundled_nvml" = "xyes"])
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/docs/getting-started.md
----------------------------------------------------------------------
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 8c72e5e..11e1d1f 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -45,7 +45,7 @@ Following are the instructions for stock Ubuntu 14.04. If you are using a differ
     $ sudo apt-get install -y autoconf libtool
 
     # Install other Mesos dependencies.
-    $ sudo apt-get -y install build-essential python-dev libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev
+    $ sudo apt-get -y install build-essential python-dev libcurl4-nss-dev libsasl2-dev libsasl2-modules maven libapr1-dev libsvn-dev libelf-dev
 
 ### Mac OS X Yosemite & El Capitan
 
@@ -112,7 +112,7 @@ Following are the instructions for stock CentOS 6.6. If you are using a differen
     $ sudo yum install -y devtoolset-2-toolchain
 
     # Install other Mesos dependencies.
-    $ sudo yum install -y apache-maven python-devel java-1.7.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel
+    $ sudo yum install -y apache-maven python-devel java-1.7.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel elfutils-libelf-devel.x86_64
 
     # Enter a shell with 'devtoolset-2' enabled.
     $ scl enable devtoolset-2 bash
@@ -163,7 +163,7 @@ Following are the instructions for stock CentOS 7.1. If you are using a differen
     $ sudo yum groupinstall -y "Development Tools"
 
     # Install other Mesos dependencies.
-    $ sudo yum install -y apache-maven python-devel java-1.8.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel
+    $ sudo yum install -y apache-maven python-devel java-1.8.0-openjdk-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-util-devel elfutils-libelf-devel.x86_64
 
 ## Building Mesos
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 20cdbf6..a493156 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -187,7 +187,9 @@ LIB_ZOOKEEPER = -lzookeeper_mt
 LDADD += -lzookeeper_mt
 endif
 
-if ENABLE_NVIDIA_GPU_SUPPORT
+# Introduced for NVIDIA GPU support (we needed to
+# introspect shared library dependencies).
+if OS_LINUX
 LIB_ELF = -lelf
 LDADD += -lelf
 endif
@@ -1036,6 +1038,8 @@ MESOS_LINUX_FILES =							\
   slave/containerizer/mesos/isolators/docker/volume/isolator.cpp	\
   slave/containerizer/mesos/isolators/filesystem/linux.cpp		\
   slave/containerizer/mesos/isolators/filesystem/shared.cpp		\
+  slave/containerizer/mesos/isolators/gpu/nvidia.cpp			\
+  slave/containerizer/mesos/isolators/gpu/nvml.cpp			\
   slave/containerizer/mesos/isolators/namespaces/pid.cpp		\
   slave/containerizer/mesos/isolators/network/cni/cni.cpp		\
   slave/containerizer/mesos/provisioner/backends/aufs.cpp		\
@@ -1061,6 +1065,8 @@ MESOS_LINUX_FILES +=							\
   slave/containerizer/mesos/isolators/docker/volume/isolator.hpp	\
   slave/containerizer/mesos/isolators/filesystem/linux.hpp		\
   slave/containerizer/mesos/isolators/filesystem/shared.hpp		\
+  slave/containerizer/mesos/isolators/gpu/nvidia.hpp 			\
+  slave/containerizer/mesos/isolators/gpu/nvml.hpp			\
   slave/containerizer/mesos/isolators/namespaces/pid.hpp		\
   slave/containerizer/mesos/isolators/network/cni/cni.hpp		\
   slave/containerizer/mesos/provisioner/backends/aufs.hpp		\
@@ -1113,14 +1119,6 @@ MESOS_NETWORK_ISOLATOR_FILES +=						\
   linux/routing/queueing/statistics.hpp					\
   slave/containerizer/mesos/isolators/network/port_mapping.hpp
 
-MESOS_NVIDIA_GPU_ISOLATOR_FILES =					\
-  slave/containerizer/mesos/isolators/gpu/nvidia.cpp			\
-  slave/containerizer/mesos/isolators/gpu/nvml.cpp
-
-MESOS_NVIDIA_GPU_ISOLATOR_FILES +=					\
-  slave/containerizer/mesos/isolators/gpu/nvidia.hpp 			\
-  slave/containerizer/mesos/isolators/gpu/nvml.hpp
-
 if OS_LINUX
 libmesos_no_3rdparty_la_SOURCES += $(MESOS_LINUX_FILES)
 else
@@ -1133,12 +1131,6 @@ else
 EXTRA_DIST += $(MESOS_NETWORK_ISOLATOR_FILES)
 endif
 
-if ENABLE_NVIDIA_GPU_SUPPORT
-libmesos_no_3rdparty_la_SOURCES += $(MESOS_NVIDIA_GPU_ISOLATOR_FILES)
-else
-EXTRA_DIST += $(MESOS_NVIDIA_GPU_ISOLATOR_FILES)
-endif
-
 libmesos_no_3rdparty_la_CPPFLAGS = $(MESOS_CPPFLAGS)
 
 libmesos_no_3rdparty_la_LIBADD = # Initialized to enable using +=.
@@ -2151,6 +2143,7 @@ mesos_tests_DEPENDENCIES =					\
 
 if OS_LINUX
 mesos_tests_SOURCES +=						\
+  tests/ldcache_tests.cpp					\
   tests/containerizer/cgroups_isolator_tests.cpp		\
   tests/containerizer/cgroups_tests.cpp				\
   tests/containerizer/cni_isolator_tests.cpp			\
@@ -2160,6 +2153,7 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/launch_tests.cpp				\
   tests/containerizer/memory_pressure_tests.cpp			\
   tests/containerizer/ns_tests.cpp				\
+  tests/containerizer/nvidia_gpu_isolator_tests.cpp		\
   tests/containerizer/perf_tests.cpp				\
   tests/containerizer/runtime_isolator_tests.cpp		\
   tests/containerizer/sched_tests.cpp				\
@@ -2172,12 +2166,6 @@ mesos_tests_SOURCES +=						\
   tests/containerizer/routing_tests.cpp
 endif
 
-if ENABLE_NVIDIA_GPU_SUPPORT
-mesos_tests_SOURCES +=						\
-  tests/ldcache_tests.cpp					\
-  tests/containerizer/nvidia_gpu_isolator_tests.cpp
-endif
-
 if HAS_JAVA
 mesos_tests_SOURCES +=						\
   tests/group_tests.cpp						\

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/src/slave/containerizer/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.cpp b/src/slave/containerizer/containerizer.cpp
index 37ce1ba..cf7fbb7 100644
--- a/src/slave/containerizer/containerizer.cpp
+++ b/src/slave/containerizer/containerizer.cpp
@@ -44,11 +44,9 @@
 #include "slave/containerizer/mesos/linux_launcher.hpp"
 #endif // __linux__
 
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
 #ifdef __linux__
 #include "slave/containerizer/mesos/isolators/gpu/nvml.hpp"
 #endif // __linux__
-#endif // ENABLE_NVIDIA_GPU_SUPPORT
 
 using std::map;
 using std::string;
@@ -99,7 +97,7 @@ Try<Resources> Containerizer::resources(const Flags& flags)
         flags.default_role).get();
   }
 
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
+#ifdef __linux__
   // GPU resource.
   // To determine the proper number of GPU resources to return, we
   // need to check both the --resources and --nvidia_gpu_devices.
@@ -180,7 +178,7 @@ Try<Resources> Containerizer::resources(const Flags& flags)
           flags.default_role).get();
     }
   }
-#endif // ENABLE_NVIDIA_GPU_SUPPORT
+#endif
 
   // Memory resource.
   if (!strings::contains(flags.resources.getOrElse(""), "mem")) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 875b024..d6a9111 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -94,11 +94,9 @@
 #include "slave/containerizer/mesos/isolators/filesystem/shared.hpp"
 #endif // __linux__
 
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
 #ifdef __linux__
 #include "slave/containerizer/mesos/isolators/gpu/nvidia.hpp"
 #endif // __linux__
-#endif // ENABLE_NVIDIA_GPU_SUPPORT
 
 #ifdef __linux__
 #include "slave/containerizer/mesos/isolators/namespaces/pid.hpp"
@@ -313,9 +311,7 @@ Try<MesosContainerizer*> MesosContainerizer::create(
     {"cgroups/perf_event", &CgroupsPerfEventIsolatorProcess::create},
     {"docker/runtime", &DockerRuntimeIsolatorProcess::create},
     {"docker/volume", &DockerVolumeIsolatorProcess::create},
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
     {"gpu/nvidia", &NvidiaGpuIsolatorProcess::create},
-#endif
     {"namespaces/pid", &NamespacesPidIsolatorProcess::create},
     {"network/cni", &NetworkCniIsolatorProcess::create},
 #endif // __linux__

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index ce2aa33..69828ae 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -381,6 +381,16 @@ mesos::internal::slave::Flags::Flags()
       "no cgroup limits are set, they are inherited from the root mesos\n"
       "cgroup.");
 
+  add(&Flags::nvidia_gpu_devices,
+      "nvidia_gpu_devices",
+      "A comma-separated list of Nvidia GPU devices. When `gpus` is\n"
+      "specified in the `--resources` flag, this flag determines which GPU\n"
+      "devices will be made available. The devices should be listed as\n"
+      "numbers that correspond to Nvidia's NVML device enumeration (as\n"
+      "seen by running the command `nvidia-smi` on an Nvidia GPU\n"
+      "equipped system).  The GPUs listed will only be isolated if the\n"
+      "`--isolation` flag contains the string `cgroups/devices/gpus/nvidia`.");
+
   add(&Flags::perf_events,
       "perf_events",
       "List of command-separated perf events to sample for each container\n"
@@ -586,18 +596,6 @@ mesos::internal::slave::Flags::Flags()
       "policy instead.",
       Seconds(0));
 
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
-  add(&Flags::nvidia_gpu_devices,
-      "nvidia_gpu_devices",
-      "A comma-separated list of Nvidia GPU devices. When `gpus` is\n"
-      "specified in the `--resources` flag, this flag determines which GPU\n"
-      "devices will be made available. The devices should be listed as\n"
-      "numbers that correspond to Nvidia's NVML device enumeration (as\n"
-      "seen by running the command `nvidia-smi` on an Nvidia GPU\n"
-      "equipped system).  The GPUs listed will only be isolated if the\n"
-      "`--isolation` flag contains the string `cgroups/devices/gpus/nvidia`.");
-#endif // ENABLE_NVIDIA_GPU_SUPPORT
-
 #ifdef WITH_NETWORK_ISOLATOR
   add(&Flags::ephemeral_ports_per_container,
       "ephemeral_ports_per_container",

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/src/slave/flags.hpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp
index 52ce503..ff45876 100644
--- a/src/slave/flags.hpp
+++ b/src/slave/flags.hpp
@@ -91,6 +91,7 @@ public:
   Option<std::string> cgroups_net_cls_primary_handle;
   Option<std::string> cgroups_net_cls_secondary_handles;
   Option<std::string> agent_subsystems;
+  Option<std::vector<unsigned int>> nvidia_gpu_devices;
   Option<std::string> perf_events;
   Duration perf_interval;
   Duration perf_duration;
@@ -117,9 +118,6 @@ public:
   std::string docker_socket;
   Option<JSON::Object> docker_config;
 
-#ifdef ENABLE_NVIDIA_GPU_SUPPORT
-  Option<std::vector<unsigned int>> nvidia_gpu_devices;
-#endif
 #ifdef WITH_NETWORK_ISOLATOR
   uint16_t ephemeral_ports_per_container;
   Option<std::string> eth0_name;

http://git-wip-us.apache.org/repos/asf/mesos/blob/03720117/support/docker_build.sh
----------------------------------------------------------------------
diff --git a/support/docker_build.sh b/support/docker_build.sh
index 82ec9e7..11799b8 100755
--- a/support/docker_build.sh
+++ b/support/docker_build.sh
@@ -43,7 +43,7 @@ case $OS in
     append_dockerfile "RUN yum groupinstall -y 'Development Tools'"
     append_dockerfile "RUN yum install -y epel-release" # Needed for clang.
     append_dockerfile "RUN yum install -y clang git maven cmake"
-    append_dockerfile "RUN yum install -y java-1.8.0-openjdk-devel python-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-utils-devel libevent-devel libev-devel"
+    append_dockerfile "RUN yum install -y java-1.8.0-openjdk-devel python-devel zlib-devel libcurl-devel openssl-devel cyrus-sasl-devel cyrus-sasl-md5 apr-devel subversion-devel apr-utils-devel libevent-devel libev-devel elfutils-libelf-devel.x86_64"
 
     # Add an unprivileged user.
     append_dockerfile "RUN adduser mesos"
@@ -63,7 +63,7 @@ case $OS in
     [ "$(uname -m)" = "x86_64" ] && CLANG_PKG=clang || CLANG_PKG=
     append_dockerfile "RUN apt-get update"
     append_dockerfile "RUN apt-get -y install build-essential $CLANG_PKG git maven autoconf libtool cmake"
-    append_dockerfile "RUN apt-get -y install openjdk-7-jdk python-dev libcurl4-nss-dev libsasl2-dev libapr1-dev libsvn-dev libevent-dev libev-dev"
+    append_dockerfile "RUN apt-get -y install openjdk-7-jdk python-dev libcurl4-nss-dev libsasl2-dev libapr1-dev libsvn-dev libevent-dev libev-dev libelf-dev"
 
     # Add an unpriviliged user.
     append_dockerfile "RUN adduser --disabled-password --gecos '' mesos"