From 85c0b374fefa5bc8a5c3036ab79ba3df78fa71d2 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 3 Jul 2025 13:41:36 -0400 Subject: Support installation on Linux4Tegra - Use alternate path if nvidia-cuda-mps-control is not found. - Work-around missing CUDA_MPS_PIPE_DIRECTORY default in L4T. - Install to L4T-specific paths if they exist. Note that CUDA_MPS_PIPE_DIRECTORY must be manually set by the user on L4T systems before they can call nvidia-cuda-mps-control, or to have to have non-nvtaskset-launched applications run with MPS. Tested on Jetson AGX Orin with L4T 36.3.0 and cuda-compat-12-6. --- Makefile | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 48047bc..406193a 100644 --- a/Makefile +++ b/Makefile @@ -71,22 +71,35 @@ clean: libsmctrl_test_next_mask libsmctrl_test_next_mask_override \ nvtaskset libcuda.so.1 +# On L4T (Linux4Tegra), the paths are different, and there may be multiple copies of libcuda.so.1 install: libcuda.so.1 - @# Check that CUDA is installed first - test -f /usr/lib/$(ARCH)/libcuda.so.*.* - @# Change libcuda.so link to bypass libcuda.so.1 - sudo ln -sf /usr/lib/$(ARCH)/libcuda.so.*.* /usr/lib/$(ARCH)/libcuda.so - @# Remove libcuda.so.1 symlink - sudo rm /usr/lib/$(ARCH)/libcuda.so.1 - @# Install wrapper as libcuda.so.1 - sudo cp libcuda.so.1 /usr/lib/$(ARCH)/libcuda.so.1 + @set -e -x; \ + for DIR in /usr/lib/$(ARCH) /usr/local/cuda-*.*/compat /usr/lib/$(ARCH)/nvidia; do \ + if [ ! -d $$DIR ]; then continue; fi; \ + # Check that CUDA is installed in this location \ + if [ ! -f $$DIR/libcuda.so.*.* ]; then continue; fi; \ + # Change libcuda.so link to bypass libcuda.so.1 \ + sudo ln -sf $$DIR/libcuda.so.*.* $$DIR/libcuda.so; \ + # Remove libcuda.so.1 symlink \ + sudo rm $$DIR/libcuda.so.1; \ + # Install wrapper as libcuda.so.1 \ + sudo cp libcuda.so.1 $$DIR/libcuda.so.1; \ + done \ + # Special handling for L4T \ + if [ -d /usr/lib/$(ARCH)/nvidia ]; then sudo ln -sf nvidia/libcuda.so.1 /usr/lib/$(ARCH)/libcuda.so.1; fi remove: - @# Test that our library in installed first - test ! -L /usr/lib/$(ARCH)/libcuda.so.1 - @# Overwrite install with original symlinks - sudo ln -sf libcuda.so.1 /usr/lib/$(ARCH)/libcuda.so - sudo ln -sf /usr/lib/$(ARCH)/libcuda.so.*.* /usr/lib/$(ARCH)/libcuda.so.1 + @set -e -x; \ + for DIR in /usr/lib/$(ARCH) /usr/local/cuda-*.*/compat /usr/lib/$(ARCH)/nvidia; do \ + if [ ! -d $$DIR ]; then continue; fi; \ + # Check that CUDA is installed in this location \ + if [ ! -f $$DIR/libcuda.so.*.* ]; then continue; fi; \ + # Test that our library in installed here \ + if [ -L $$DIR/libcuda.so.1 ]; then continue; fi; \ + # Overwrite install with original symlinks \ + sudo ln -sf libcuda.so.1 $$DIR/libcuda.so; \ + sudo ln -sf $$DIR/libcuda.so.*.* $$DIR/libcuda.so.1; \ + done run_tests: tests ./libsmctrl_test_global_mask -- cgit v1.2.2