Reputation: 577
I am trying to execute some CUDA code which happens to have some NVML library functions like nvmlSystemGetDriverVersion. But, when I try to compile the code it says nvml.h not found. How should I install NVML on my system since nvml.h does not seem to be present on it?
Upvotes: 3
Views: 8383
Reputation: 15925
It depends on your operating system. I'm using Ubuntu Linux and there you can query the correct package name via packages.ubuntu.com:
https://packages.ubuntu.com/search?searchon=contents&keywords=nvml.h
I assume we know that CUDA is Nvidia proprietary technology so we know that the package called libnvidia-ml-dev
is the correct one (there's another package called libhwloc-dev
that also contains a file called nvml.h
). To install it, you can simply run command
sudo apt install libnvidia-ml-dev
and you'll be done. The correct file can be found in location /usr/include/nvml.h
and should be picked up automatically by your compiler.
If you use some operating system without a working package manager (such as Microsoft Windows) I guess you'll be hunting the internet for random installer files to execute and hope that you end up with the correct file.
(If you often need to do this kind of stuff, Ubuntu also supports command apt-file search nvml.h
but that requires fetching quite a big search index from the internet before first reply and for a single file it's faster to use cloud service instead.)
Upvotes: 0
Reputation: 151849
A google search of "nvidia nvml" returns this as the first link. This page contains links for the API documentation.
On that page, if you click on the Tesla Deployment Kit link, you can then find the download links appropriate for your OS (windows or linux) and CUDA version (cuda 5.0 or cuda 4.2)
The Tesla Deployment kit contains the header file you mention (nvml.h) as well as some libraries you will probably need to link against, in order to use the NVML functions.
There are sample build projects including makefiles in the Tesla Deployment Kit which should answer any questions about how to compile and link using assets from the kit.
EDIT: there is an example project in .../tdk_3.xxxx/nvml/example There is a sample makefile in that example project directory. If you inspect that makefile, you'll see that to link in the nvml library your compile command will need to include something like:
-L/path/to/nvml/lib64/ -lnvidia-ml
Upvotes: 4