Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"NBFC isn't showing my GPU Temps, only shows the CPU temps?" #203

Closed
NicholasLAranda opened this issue Mar 19, 2017 · 21 comments
Closed

"NBFC isn't showing my GPU Temps, only shows the CPU temps?" #203

NicholasLAranda opened this issue Mar 19, 2017 · 21 comments

Comments

@NicholasLAranda
Copy link
Contributor

This is because Windows Services do not have access to GPU Temperatures, and NoteBook FanControl runs as a Windows service.

As per the developer of NBFC @hirschmann outlined in this comment: #33 (comment)

"On Windows: services do not have access to the GPU.
Since NBFC runs as a service: it can not read the GPU temperature.
Currently, I don't know of a good solution for this limitation, sorry."

This explains why in Windows we only have the CPU temperature, even though we have full control over the GPU fan.

I made this issue so that multiple existing issues can be closed and merged to this one, in attempts to lessen the amount of open issues @hirschmann will need to manage.

@hirschmann
Copy link
Owner

I'll try to shed some (more) light on this problem:
With Windows Vista, MS introduced session 0 isolation, which means services run in a non-interactive session.
Unfortunately this means they can't access the GPU directly, which is the reason why the NBFC service still can't read GPU temperatures.

When I say "I don't know of a good solution for this limitation", I mean there is a solution, but in my opinion it's not reliable enough and that's why I haven't implemented it (yet).
It would be possible to run a process, which monitors the GPU temperature and reports it back to the service, in an interactive (user) session. But as soon as the user logs off from the session, the monitoring process would be stopped by the OS and NBFC would be "cut off" from the GPU.
Obviously, an unreliable (or not existing) temperature source is a really big problem for NBFC.

If anyone wants to discuss this problem or knows how to solve it, feel free to post your thoughts here.

@snow3461
Copy link

Why is it different for the CPU? Is that because GPU driver runs in session 1 instead of session 0?

@hirschmann
Copy link
Owner

hirschmann commented Mar 20, 2017

It's a little more complicated than that.
The short answer is:
Unlike process which run in interactive user sessions, services which run in session 0 can't access graphics devices (the Windows graphics API call to create a graphics device just fails), because they shouldn't be able to interact with the user e.g. by creating a Window on the Desktop.

Unfortunately this also means, libraries like NVAPI and AMD display library can't access the gpu from session 0.

Since NBFC relies on these libraries, it fails to read the GPU temperatures when running in session 0, see:
https://github.com/hirschmann/nbfc/tree/master/Core/Plugins/OpenHardwareMonitor/Hardware/Nvidia
https://github.com/hirschmann/nbfc/tree/master/Core/Plugins/OpenHardwareMonitor/Hardware/ATI

If you want to learn more about session 0 isolation and WDDM, have a look at these articles:

@snow3461
Copy link

Thank you, I will.

@NicholasLAranda
Copy link
Contributor Author

NicholasLAranda commented Mar 24, 2017

Have you seen these @hirschmann :

http://stackoverflow.com/a/16320043
http://stackoverflow.com/a/18221151

https://msdn.microsoft.com/en-us/windows7trainingcourse_win7session0isolation_topic1#_Toc243675528
More links to the right

https://msdn.microsoft.com/en-us/library/windows/hardware/dn305135(v=vs.85).aspx
https://msdn.microsoft.com/en-us/library/windows/hardware/hh439923(v=vs.85).aspx

Other than that: you literally need to hack Windows in order to accomplish a "Session 0 Isolation", which currently has NOT bee achieved yet.

I want to help you achieve this!

@NicholasLAranda
Copy link
Contributor Author

NicholasLAranda commented Mar 24, 2017

How do other programs like OpenHardware monitor and nVidiaInspector or really any other program, access GPU temps?

Are they false readings? Couldn't you borrow some code (with credits) to enable this?

I wanna help. I don't know how to compile, but I do know how to "add code" that the program can utilize.

If I find code, can you add the GUI element, can you program it to pull GPU temps and display on-screen in the GUI, then adjust based off the gathering of this data?

@snow3461
Copy link

@RypeDub420 If my understanding is correct, NBFC runs as a service, and as thus run in session0, which is (or not perfectly as you may have pointed out) isolated from user session.
OpenHardwareMonitor runs in user session so has access to the GPU.

@hirschmann
Copy link
Owner

@RypeDub420
Thanks for trying to help.
I've tried to clean up the thread and thus have deleted the links to the outdated openhardwaremonitor fork you've posted. I hope you don't mind.

This is the official OHM repo:
https://github.com/openhardwaremonitor/openhardwaremonitor

This is the OHM fork inside the NBFC repo, which NBFC uses (on Windows) to read temperatures and access the EC:
https://github.com/hirschmann/nbfc/tree/master/Core/Plugins/OpenHardwareMonitor

As @snow3461 said, NBFC would be able to read the GPU temperatures, its just not possible from session 0 in general.

@NicholasLAranda
Copy link
Contributor Author

NicholasLAranda commented Mar 26, 2017

Couldn't we then run a non-gui process, that hooks into nbfc.exe so the task manager doesnt get filled up lol, that's not session zero, have it output to a file, then have the nbfc service read from the file in order to display temps and utilize that data to control the fan, instead of being linked to þe cpu temp?

The delay between changing the sliders and displaying the fan speed change is already enough to accommodate this small data gathering process.

Also, I don't mind you cleaning up. I just wanted to point directly to þe code so you arent sifting through every file like I did.

@mirh
Copy link

mirh commented Mar 26, 2017

Having programs read from a file seems dirt as mud.

I think we could consider this depending on openhardwaremonitor/openhardwaremonitor#33 then?
Last comments suggest schtasks to be the solution.

@NicholasLAranda
Copy link
Contributor Author

If nbfc runs in session 0 cause it's a service, then have it run as a process not in session 0, SPAWN the service in session 0, then that will allow you to use schtasks, correct?

@mirh
Copy link

mirh commented Mar 27, 2017

Afaik the idea was supposed to just be: run nbfc as a task on start/boot, profit.
Services for reasons explained here really don't seem viable.

@NicholasLAranda
Copy link
Contributor Author

Maybe it's time to evolve NBFC, perhaps introduce a new GUI and the ability to automatically submit config's.

I just really love this program and I wanna see it grow :D

@mirh
Copy link

mirh commented Mar 27, 2017

Tbh, if you have the ability to mess up with EC registers, doing a pull request really seem the least of your problems.
If any, I'd see light years of room for improvements in tools to help figuring out those (I'm working on a dumb idea of mine in this regard).

For example: how about cross-comparing temperature (or fan speed RPMs if that info is available somewhere else) change moments with EC registers changes?
Or perhaps porting this stuff.
Also making a wiki page to merge guides and user manual.

@DrOfIllusions
Copy link

DrOfIllusions commented Feb 2, 2018

Hi,

I was looking into a similar matter concerning my Zbook 17. I was wondering if it would not be easier to just write a batch file that runs at Logon in the background and continuously reads the temperature/Power load from nvsmi.exe (NVIDIA GPU) and then issues a command to Notebook FanControl to move to a certain fan percent. Is this possible? If so, can someone give me a weblink to somewhere that shows how to code such a thing?

Thanks!
DOI

@mirh
Copy link

mirh commented Feb 2, 2018

It certainly is possible. but that's really hacky at best.
I wonder if vendor-specific apis couldn't be used then?

@DrOfIllusions
Copy link

Great! Thanks! So if I want to communicate with NBFC from either C or the CMD line, once I get the temperatures and my temperature thresholds are met, how to do that?

I was actually looking into exploiting the following Nvidia command from the CMD line in a batch file:

nvidia-smi.exe -i 0 --loop-ms=100 --format=csv,noheader --query-gpu=temperature.gpu

The idea was that every 100ms the GPU parameter I would like to control (for me power would be better as it is an early indicator of the gpu temperature) is automatically measured. At each measurement then I would run the threshold checks and issue the corresponding command to NBFC (Perhaps it would be better to just run EC-probe.exe with the write command?). What is bothering me though is how can I in a batch file read the stdout of a polling program at each poll and act on it without interrupting the poll.

Any help is highly appreciated,

Thanks!

@chandradeepdey
Copy link
Contributor

chandradeepdey commented Nov 5, 2018

On my laptop, the EC itself can be used to find out temperatures. Do other laptops also support this?

image
Fan 1 is CPU temp (reading from 0xB0), Fan 2 is GPU temp (reading from 0xB4)

@chandradeepdey
Copy link
Contributor

The following solution is based on how my laptop works:
We can let the user add a config to individual fans about which registers to read the temperature from. We can also let the user add weights to the registers. While calculating the register, we can do a weighted mean of all nonzero registers.
This allows the CPU fan to only use the CPU temperature. This also allows the GPU fan to be able to properly select the temperature to respond to. When the GPU is active, the weighted mean of both the registers are used. When the GPU is inactive, and the temperature shows up as 00, only the CPU register is considered.

@saravanabalagi
Copy link

@chandradeepdey Same here, my temperatures show up in the EC at registers 164 and 166 for GPU and CPU respectively and I believe we can make use of this for comps that have this setup.

Also observing the EC, I see that register 160 is almost always carry the same value as 166 and so does 164 and 165. I'm still puzzled about a few things though, my config writes 0x0A (10) to registers 160 and 166 before writing the fan speed values at 151 and 152, however when the speed changes automatically it doesn't happen, is that some sort of write switch?

@github-actions
Copy link

This issue is stale because it has been open more than 180 days with no activity. If nobody comments within 7 days, this issue will be closed

@github-actions github-actions bot added the Stale label Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants