Skip to contentSkip to conversation

package/nvidia-driver: CUDA can be used without X.org (branch yem/nvidia-cuda)

PATCH New Yann E. MORIN 2 participants 4 messages Mar 31, 2015 – Apr 1, 2015

lore
Share & tools
lore
#0 lore raw

cover package/nvidia-driver: CUDA can be used without X.org (branch yem/nvidia-cuda)

Hello All!

This series allows one to use nvidia-driver to do CUDA without requiring the X.org stack.

Thanks to Al for reporting the issue and testing the patches out-of-band! ;-)

Regards,
Yann E. MORIN.

The following changes since commit 8ef3745617ca48c683480223fe851eeb72f115ea:

libgtk3: bump to version 3.14.11 (2015-03-31 14:00:51 +0200)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot yem/nvidia-cuda

for you to fetch changes up to c5c6f5405c36249f6d67a8180e8502e17f59e01a:

package/nvidia-driver: add option to install CUDA MPS server (2015-03-31 19:34:02 +0200)

----------------------------------------------------------------
Yann E. MORIN (2):
package/nvidia-driver: CUDA support does not require X.org package/nvidia-driver: add option to install CUDA MPS server

 package/nvidia-driver/Config.in        | 53 ++++++++++++++++++++++++----------
 package/nvidia-driver/nvidia-driver.mk | 29 +++++++++++++------
 2 files changed, 57 insertions(+), 25 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 1/2 package/nvidia-driver: CUDA support does not require X.org

Currently, nvidia-driver always installs the X.org driver, assuming this is a requirement for all functionalities provided by nvidia-driver, thus pulling in quite a bunch of X.org packages.

However, it is perfectly legit to be doing CUDA (and OpenCL) work without the full X.org stack, and indeed the NVidia CUDA and OpenCL libraries do not require the X.org stack.

Split the configuration so that it is posible to install the different parts independently from each others, so that CUDA can be installed all on its own.

---
 package/nvidia-driver/Config.in        | 42 +++++++++++++++++++++-------------
 package/nvidia-driver/nvidia-driver.mk | 22 ++++++++++--------
 2 files changed, 39 insertions(+), 25 deletions(-)
package/nvidia-driver/Config.in +26 -16
index cd7fc95..a63576c 100644
@@ -1,12 +1,25 @@
-comment "nvidia-driver needs an (e)glibc toolchain and a modular Xorg server"
+comment "nvidia-driver needs an (e)glibc toolchain"
 	depends on BR2_i386 || BR2_x86_64
-	depends on !BR2_TOOLCHAIN_USES_GLIBC \
-		|| !BR2_PACKAGE_XSERVER_XORG_SERVER_MODULAR
+	depends on !BR2_TOOLCHAIN_USES_GLIBC
 
 config BR2_PACKAGE_NVIDIA_DRIVER
 	bool "nvidia-driver"
 	depends on BR2_i386 || BR2_x86_64
 	depends on BR2_TOOLCHAIN_USES_GLIBC
+	help
+	  The binary-only driver blob for NVidia cards.
+	  This is the userland part only.
+
+	  http://www.nvidia.com/
+
+if BR2_PACKAGE_NVIDIA_DRIVER
+
+comment "nvidia-driver X.org drivers needs a modular Xorg server"
+	depends on !BR2_PACKAGE_XSERVER_XORG_SERVER_MODULAR
+
+config BR2_PACKAGE_NVIDIA_DRIVER_XORG
+	bool "X.org drivers"
+	default y
 	depends on BR2_PACKAGE_XSERVER_XORG_SERVER_MODULAR
 	select BR2_PACKAGE_MESA3D_HEADERS
 	select BR2_PACKAGE_XLIB_LIBX11
@@ -14,13 +27,8 @@ config BR2_PACKAGE_NVIDIA_DRIVER
 	select BR2_PACKAGE_HAS_LIBGL
 	select BR2_PACKAGE_HAS_LIBEGL
 	select BR2_PACKAGE_HAS_LIBGLES
-	help
-	  The binary-only driver blob for NVidia cards.
-	  This is the userland part only.
 
-	  http://www.nvidia.com/
-
-if BR2_PACKAGE_NVIDIA_DRIVER
+if BR2_PACKAGE_NVIDIA_DRIVER_XORG
 
 config BR2_PACKAGE_PROVIDES_LIBGL
 	default "nvidia-driver"
@@ -31,13 +39,6 @@ config BR2_PACKAGE_PROVIDES_LIBEGL
 config BR2_PACKAGE_PROVIDES_LIBGLES
 	default "nvidia-driver"
 
-config BR2_PACKAGE_NVIDIA_DRIVER_CUDA
-	bool "CUDA support"
-
-config BR2_PACKAGE_NVIDIA_DRIVER_OPENCL
-	bool "OpenCL support"
-	depends on BR2_PACKAGE_NVIDIA_DRIVER_CUDA
-
 config BR2_PACKAGE_NVIDIA_DRIVER_PRIVATE_LIBS
 	bool "Install private libraries"
 	help
@@ -49,6 +50,15 @@ config BR2_PACKAGE_NVIDIA_DRIVER_PRIVATE_LIBS
 	  Say 'y' here if you plan on running a program that uses
 	  those private libraries.
 
+endif # BR2_PACKAGE_NVIDIA_DRIVER_XORG
+
+config BR2_PACKAGE_NVIDIA_DRIVER_CUDA
+	bool "CUDA support"
+
+config BR2_PACKAGE_NVIDIA_DRIVER_OPENCL
+	bool "OpenCL support"
+	depends on BR2_PACKAGE_NVIDIA_DRIVER_CUDA
+
 comment "nvidia kernel module needs a kernel to be built"
 	depends on !BR2_LINUX_KERNEL
 
package/nvidia-driver/nvidia-driver.mk +13 -9
index 4605d02..454209a 100644
@@ -13,6 +13,8 @@ NVIDIA_DRIVER_LICENSE_FILES = LICENSE
 NVIDIA_DRIVER_REDISTRIBUTE = NO
 NVIDIA_DRIVER_INSTALL_STAGING = YES
 
+ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_XORG),y)
+
 # Since nvidia-driver are binary blobs, the below dependencies are not
 # strictly speaking build dependencies of nvidia-driver. However, they
 # are build dependencies of packages that depend on nvidia-driver, so
@@ -38,15 +40,6 @@ NVIDIA_DRIVER_LIBS = \
 	libvdpau libvdpau_nvidia \
 	libnvidia-ml
 
-ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),y)
-NVIDIA_DRIVER_LIBS += libcuda libnvidia-compiler libnvcuvid libnvidia-encode
-endif
-
-ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_OPENCL),y)
-NVIDIA_DRIVER_LIBS_NO_VERSION += libOpenCL.so.1.0.0
-NVIDIA_DRIVER_LIBS += libnvidia-opencl
-endif
-
 # Those libraries are 'private' libraries requiring an agreement with
 # NVidia to develop code for those libs. There seems to be no restriction
 # on using those libraries (e.g. if the user has such an agreement, or
@@ -60,6 +53,17 @@ NVIDIA_DRIVER_X_MODS = drivers/nvidia_drv.so \
 	extensions/libglx.so.$(NVIDIA_DRIVER_VERSION) \
 	libnvidia-wfb.so.$(NVIDIA_DRIVER_VERSION)
 
+endif # X drivers
+
+ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),y)
+NVIDIA_DRIVER_LIBS += libcuda libnvidia-compiler libnvcuvid libnvidia-encode
+endif
+
+ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_OPENCL),y)
+NVIDIA_DRIVER_LIBS_NO_VERSION += libOpenCL.so.1.0.0
+NVIDIA_DRIVER_LIBS += libnvidia-opencl
+endif
+
 # The downloaded archive is in fact an auto-extract script. So, it can run
 # virtually everywhere, and it is fine enough to provide useful options.
 # Except it can't extract into an existing (even empty) directory.
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 package/nvidia-driver: add option to install CUDA MPS server

In reply to Yann E. MORIN

Using CUDA with NVidia requires those two programs if one wants to use more than one program doing CUDA at the same time.

This is only available on x86_64.

---
 package/nvidia-driver/Config.in        | 13 ++++++++++++-
 package/nvidia-driver/nvidia-driver.mk |  7 +++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
package/nvidia-driver/Config.in +12 -1
index a63576c..b50e2c3 100644
@@ -55,9 +55,20 @@ endif # BR2_PACKAGE_NVIDIA_DRIVER_XORG
 config BR2_PACKAGE_NVIDIA_DRIVER_CUDA
 	bool "CUDA support"
 
+if BR2_PACKAGE_NVIDIA_DRIVER_CUDA
+
 config BR2_PACKAGE_NVIDIA_DRIVER_OPENCL
 	bool "OpenCL support"
-	depends on BR2_PACKAGE_NVIDIA_DRIVER_CUDA
+
+config BR2_PACKAGE_NVIDIA_DRIVER_CUDA_PROGS
+	bool "CUDA MPS server and control"
+	depends on BR2_x86_64
+	help
+	  Say 'y' here if you need to run more than one program
+	  doing CUDA at the same time. The MPS server will be
+	  launched automatically when needed.
+
+endif # BR2_PACKAGE_NVIDIA_DRIVER_CUDA
 
 comment "nvidia kernel module needs a kernel to be built"
 	depends on !BR2_LINUX_KERNEL
package/nvidia-driver/nvidia-driver.mk +7 -0
index 454209a..a85cc1c 100644
@@ -57,6 +57,9 @@ endif # X drivers
 
 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA),y)
 NVIDIA_DRIVER_LIBS += libcuda libnvidia-compiler libnvcuvid libnvidia-encode
+ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_CUDA_PROGS),y)
+NVIDIA_DRIVER_PROGS = nvidia-cuda-mps-control nvidia-cuda-mps-server
+endif
 endif
 
 ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_OPENCL),y)
@@ -165,6 +168,10 @@ define NVIDIA_DRIVER_INSTALL_TARGET_CMDS
 		$(INSTALL) -D -m 0644 $(@D)/$${m##*/} \
 			$(TARGET_DIR)/usr/lib/xorg/modules/$${m}; \
 	done
+	for p in $(NVIDIA_DRIVER_PROGS); do \
+		$(INSTALL) -D -m 0755 $(@D)/$${p} \
+			$(TARGET_DIR)/usr/bin/$${p}; \
+	done
 	$(NVIDIA_DRIVER_INSTALL_KERNEL_MODULE)
 endef
 
Signature · 1 line
1.9.1
#3 lore raw

cover package/nvidia-driver: CUDA can be used without X.org (branch yem/nvidia-cuda)

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 3 lines · Yann E. MORIN

Yann E. MORIN (2):
package/nvidia-driver: CUDA support does not require X.org package/nvidia-driver: add option to install CUDA MPS server

Applied, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com