diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2025-07-03 13:41:36 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2025-07-03 13:49:18 -0400 |
commit | 85c0b374fefa5bc8a5c3036ab79ba3df78fa71d2 (patch) | |
tree | 0f0958b307d1d354ad02832a6244aa3fd3882c32 /nvtaskset.c | |
parent | 9b4b4f71fd843c3ec97ca6f55935675e62ca31f5 (diff) |
Support installation on Linux4Tegraecrts25-ae
- 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.
Diffstat (limited to 'nvtaskset.c')
-rw-r--r-- | nvtaskset.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/nvtaskset.c b/nvtaskset.c index 5cf3a85..3a50221 100644 --- a/nvtaskset.c +++ b/nvtaskset.c | |||
@@ -359,16 +359,34 @@ static error_t arg_parser(int key, char* arg, struct argp_state *state){ | |||
359 | else | 359 | else |
360 | printf("PID %d's current TPC affinity mask: 0x%.0lx%016lx\n", target_pid, (uint64_t)(enable_mask >> 64), (uint64_t)enable_mask); | 360 | printf("PID %d's current TPC affinity mask: 0x%.0lx%016lx\n", target_pid, (uint64_t)(enable_mask >> 64), (uint64_t)enable_mask); |
361 | } else if (is_cmd) { | 361 | } else if (is_cmd) { |
362 | if (!getenv("CUDA_MPS_PIPE_DIRECTORY")) { | ||
363 | // Pipe directory is not set by default on L4T aarch64 | ||
364 | putenv("CUDA_MPS_PIPE_DIRECTORY=/tmp/nvidia-mps"); | ||
365 | } | ||
362 | // start MPS (as needed) | 366 | // start MPS (as needed) |
363 | if (!libsmctrl_is_mps_running()) { | 367 | if (!libsmctrl_is_mps_running()) { |
364 | fprintf(stderr, "nvtaskset: MPS control deamon does not appear to be running. Automatically starting...\n"); | 368 | fprintf(stderr, "nvtaskset: MPS control deamon does not appear to be running. Automatically starting...\n"); |
369 | // TODO: Mute the error message if this command isn't found? | ||
365 | int ret = system("nvidia-cuda-mps-control -d"); | 370 | int ret = system("nvidia-cuda-mps-control -d"); |
371 | // TODO: Fall back to full x86_64 install location? | ||
372 | // Fall back to full L4T aarch64 install location | ||
373 | if (ret == 0x7f00) { | ||
374 | // nvidia-cuda-mps-control needs nvidia-cuda-mps-server to be on PATH | ||
375 | char *old_path = getenv("PATH"); | ||
376 | char *new_path; | ||
377 | if (old_path) | ||
378 | asprintf(&new_path, "PATH=/usr/local/cuda/compat/:%s", old_path); | ||
379 | else | ||
380 | new_path = "PATH=/usr/local/cuda/compat/"; | ||
381 | putenv(new_path); | ||
382 | ret = system("nvidia-cuda-mps-control -d"); | ||
383 | // TODO: Put this warning after error checking | ||
384 | fprintf(stderr, "nvtaskset: Warning: Set the CUDA_MPS_PIPE_DIRECTORY environment variable to /tmp/nvidia-mps to ensure that subsequently launched tasks associate with MPS on L4T systems!\n"); | ||
385 | } | ||
366 | if (ret == -1) | 386 | if (ret == -1) |
367 | error(1, errno, "Unable to run subshell to start MPS"); | 387 | error(1, errno, "Unable to run subshell to start MPS"); |
368 | if (ret == 1) { | 388 | else if (ret) |
369 | fprintf(stderr, "nvtaskset: Error starting MPS control deamon. Terminating...\n"); | 389 | error(1, 0, "Error starting MPS control deamon. Terminating..."); |
370 | return 1; | ||
371 | } | ||
372 | fprintf(stderr, "nvtaskset: Done. Use \"echo quit | nvidia-cuda-mps-control\" to terminate it later as desired.\n"); | 390 | fprintf(stderr, "nvtaskset: Done. Use \"echo quit | nvidia-cuda-mps-control\" to terminate it later as desired.\n"); |
373 | } | 391 | } |
374 | // launch subprocess | 392 | // launch subprocess |
@@ -377,6 +395,7 @@ static error_t arg_parser(int key, char* arg, struct argp_state *state){ | |||
377 | snprintf(mask_str, 36, "~0x%.0lx%016lx", (uint64_t)(mask >> 64), (uint64_t)mask); | 395 | snprintf(mask_str, 36, "~0x%.0lx%016lx", (uint64_t)(mask >> 64), (uint64_t)mask); |
378 | setenv("LIBSMCTRL_MASK", mask_str, 1); | 396 | setenv("LIBSMCTRL_MASK", mask_str, 1); |
379 | // Start task | 397 | // Start task |
398 | // TODO: Check that the loader is configured to find the corrrect libcuda.so.1 | ||
380 | execvp(sub_argv[0], sub_argv); | 399 | execvp(sub_argv[0], sub_argv); |
381 | error(1, errno, "Unable to launch task '%s'", sub_argv[0]); | 400 | error(1, errno, "Unable to launch task '%s'", sub_argv[0]); |
382 | } else { | 401 | } else { |