Skip to content

Depend on NVML only, not the full CUDA toolkit - #77

Open
Mob97 wants to merge 2 commits into
justanhduc:masterfrom
Mob97:feat/find-nvml
Open

Depend on NVML only, not the full CUDA toolkit#77
Mob97 wants to merge 2 commits into
justanhduc:masterfrom
Mob97:feat/find-nvml

Conversation

@Mob97

@Mob97 Mob97 commented Aug 6, 2026

Copy link
Copy Markdown

gpu.c uses NVML (nvmlInit, nvmlDeviceGetMemoryInfo) -- the management library that ships with the NVIDIA driver and backs nvidia-smi -- and never touches the CUDA compute runtime. The build nevertheless required find_package(CUDA REQUIRED) and linked -lcudart -lcublas, so a host with a perfectly good driver could not build the GPU version without installing the entire toolkit. A grep for cuda_runtime/cublas/cudaMalloc/cudaMemcpy across the tree finds no user of either library outside that link line.

Add cmake/FindNVML.cmake, which looks for nvml.h and the nvidia-ml library in driver locations directly and treats CUDA_HOME/CUDA_PATH/CUDA_ROOT as optional search hints rather than requirements. Two cases needed care:

  • Driver-only hosts often ship libnvidia-ml.so.1 without the unversioned symlink find_library() looks for, so fall back to find_file() on the versioned soname and link it by absolute path.
  • WSL2 exposes the Windows driver under /usr/lib/wsl/lib, which is not a standard library directory, so search it explicitly.

The Makefile now links -lnvidia-ml alone, with CUDA_HOME used only as a hint if set. Verified on a driver-only host with no CUDA toolkit: the GPU build links and ldd ts resolves libnvidia-ml.so.1 to the driver.

Document where nvml.h actually comes from. It is not part of any driver; on Debian/Ubuntu it is libnvidia-ml-dev, whose only payload is /usr/include/nvml.h. Also note the /usr/include/hwloc/nvml.h decoy, which is an unrelated file that a naive search will find.

The TASK_SPOOLER_COMPILE_CUDA option name is kept as-is for backward compatibility with existing build scripts.

minhbq and others added 2 commits August 6, 2026 11:25
gpu.c uses NVML (nvmlInit, nvmlDeviceGetMemoryInfo) -- the management library
that ships with the NVIDIA driver and backs nvidia-smi -- and never touches the
CUDA compute runtime. The build nevertheless required find_package(CUDA
REQUIRED) and linked -lcudart -lcublas, so a host with a perfectly good driver
could not build the GPU version without installing the entire toolkit. A grep
for cuda_runtime/cublas/cudaMalloc/cudaMemcpy across the tree finds no user of
either library outside that link line.

Add cmake/FindNVML.cmake, which looks for nvml.h and the nvidia-ml library in
driver locations directly and treats CUDA_HOME/CUDA_PATH/CUDA_ROOT as optional
search hints rather than requirements. Two cases needed care:

  - Driver-only hosts often ship libnvidia-ml.so.1 without the unversioned
    symlink find_library() looks for, so fall back to find_file() on the
    versioned soname and link it by absolute path.
  - WSL2 exposes the Windows driver under /usr/lib/wsl/lib, which is not a
    standard library directory, so search it explicitly.

The Makefile now links -lnvidia-ml alone, with CUDA_HOME used only as a hint if
set. Verified on a driver-only host with no CUDA toolkit: the GPU build links
and `ldd ts` resolves libnvidia-ml.so.1 to the driver.

Document where nvml.h actually comes from. It is not part of any driver;
on Debian/Ubuntu it is libnvidia-ml-dev, whose only payload is
/usr/include/nvml.h. Also note the /usr/include/hwloc/nvml.h decoy, which is an
unrelated file that a naive search will find.

The TASK_SPOOLER_COMPILE_CUDA option name is kept as-is for backward
compatibility with existing build scripts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Neither README nor INSTALL.md said what to install. The GPU build in
particular gave no hint that it needs nvml.h, which no NVIDIA driver ships --
a working nvidia-smi tells you nothing about build-time files.

Split the list by build-time and run-time, since they differ sharply. The CPU
binary links nothing but libc (verified with ldd), and the GPU binary adds only
libnvidia-ml.so.1 from the driver. The remaining run-time entries are optional
and tied to specific flags: gzip for -z (execute.c:128) and an MTA at
/usr/sbin/sendmail for -m (mail.c:37).

Note that the RHEL/Fedora NVML header package lives in NVIDIA's own CUDA
repository rather than the base repositories, which is easy to trip over.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant