Comments (2)
We are using nvmlDeviceGetFanSpeed
, but another API nvmlUnitGetFanSpeedInfo
seems to allow reading of RPM values.
- https://docs.nvidia.com/deploy/nvml-api/group__nvmlUnitQueries.html#group__nvmlUnitQueries_1gf8d512cb5764d671c8bd6b0ef32ae456
- https://docs.nvidia.com/deploy/nvml-api/structnvmlUnitFanSpeeds__t.html#structnvmlUnitFanSpeeds__t
from gpustat.
I already tried it but it does not seem to work in my case (RTX 3080). I got an "Invalid argument" exception. I guess it is only intended to be used with a specific class of GPU models (S-class unit).
So finally I was able to compile a simple snippet of C code to get what I wanted.
I exploit the NVCtrl library.
Check this thread (me author) on ubuntuforums.
Here is the snippet:
/*
Compile:
gcc -o get_GPU_fan_RPM_values get_GPU_fan_RPM_values.c -lX11 -lXNVCtrl
Usage:
./get_GPU_fan_RPM_values <fan_id>
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <X11/Xlib.h>
#include <NVCtrl/NVCtrl.h>
#include <NVCtrl/NVCtrlLib.h>
static Display *display;
static double get_att(int target, int id, int att)
{
Bool res;
int temp;
res = XNVCTRLQueryTargetAttribute(display, target, id, 0, att, &temp);
if (res == True)
return temp;
return -1;
}
void nvidia_cleanup(void)
{
if (display) {
XCloseDisplay(display);
display = NULL;
}
}
bool isFanId(char number[])
{
int i = 0;
if (number[0] == '-')
return false;
for (; number[i] != 0; i++)
{
if (number[i] > '1' || number[i] < '0')
return false;
}
return true;
}
int main(int argc, char** argv) {
if ( !(argc == 2) ) {
printf("Please, provide the fan ID.\n");
return 1;
}
if ( !isFanId(argv[1]) ) {
printf("There is no fan with ID %d.\n", atoi(argv[1]));
return 1;
}
int fanId = atoi(argv[1]);
display = XOpenDisplay(NULL);
if (!display) {
printf("Cannot open connection to X11 server.\n");
nvidia_cleanup();
return 1;
}
int evt, err;
if (!XNVCTRLQueryExtension(display, &evt, &err)) {
printf("XNVCTRLQueryExtension error %d (evt %d).\n", err, evt);
nvidia_cleanup();
return 1;
}
printf("%d\n", (int)get_att(NV_CTRL_TARGET_TYPE_COOLER, fanId, NV_CTRL_THERMAL_COOLER_SPEED));
nvidia_cleanup();
return 0;
}
from gpustat.
Related Issues (20)
- Some low-level errors (like `pynvml.nvml.NVMLError_LibRmVersionMismatch`) result in nothing printed (std or diagnostic) HOT 1
- UserWarning: Failed to setupterm(kind='xterm'): setupterm: could not find terminfo database HOT 1
- Support anaconda's legacy pynvml package HOT 7
- Plugin Architecture
- module 'pynvml' has no attribute '_nvmlGetFunctionPointer' HOT 17
- Truncate the "command" when use "-f" HOT 1
- ModuleNotFoundError: No module named '_curses' HOT 2
- ModuleNotFoundError: No module named '_curses' HOT 2
- Process not displayed HOT 3
- make appimage format or binary file οΌit can run everywhere HOT 1
- make appimage format HOT 1
- Error on querying NVIDIA devices | OverflowError: Python int too large to convert to C long HOT 9
- gpustat reports only the first program on nv driver 535 HOT 4
- Include GDDR6(X) VRAM temperatures HOT 2
- Show CUDA Driver Version in the output HOT 2
- Enhance gpustat to Display Latest CUDA Version Compatible with Current NVIDIA Driver HOT 4
- Even more compact (single-line) output for statusline use HOT 2
- Misreported used memory with the driver 535.129.03 HOT 3
- /usr/bin/gpustat:6: DeprecationWarning: pkg_resources is deprecated as an API. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpustat.