diff options
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 { |
