On limiting GPU usage

Moderators: Site Moderators, FAHC Science Team

On limiting GPU usage

Postby danielocdh » Thu Apr 06, 2017 10:01 pm

Is there an option to limit GPU usage?
I'd rather run my GPU at 20-40% for 10 hours while my computer is being used than AFK GPU at 100% for 1 hour.

If the option isn't there please consider creating it, I know it might be complicated but totally worth it for users like me.

Thanks
danielocdh
 
Posts: 4
Joined: Thu Apr 06, 2017 9:56 pm

Re: On limiting GPU usage

Postby bruce » Thu Apr 06, 2017 10:55 pm

No.

A GPU is either ON or OFF.

The only intermediate setting for a GPU is to set IDLE to TRUE. That will ask FAH to configure the OS so that it treats the GPU in a similar way that the OS treats a screensaver. If the keyboard/mouse are inactive for a while, the GPU starts processing. If you use the keyboard/mouse the OS sets itself to active and GPU processing is suspended. That setting should prevent "screen lag" which is generally a result of FAH using nearly 100% of the GPU's resources when you're not using the computer and suspending processing when you want to see prompt video response.

It's also possible to configure your browser / video player / etc. to use CPU resources instead of GPU resources, which may provide you wit prompt video updates even when the GPU is busy folding.
bruce
 
Posts: 20009
Joined: Thu Nov 29, 2007 11:13 pm
Location: So. Cal.

Re: On limiting GPU usage

Postby JimboPalmer » Thu Apr 06, 2017 11:24 pm

Operating systems for CPUs started trying to share between applications in the 1950's. They are very good at it now and there are almost no troubles with running CPU tasks in the background. (In 1978, when I started using computers I used one computer to word process, one to spell check, and one to print, as CPU sharing had not made it to CP/M microcomputers) GPUs still have no operating system even trying to prioritize applications, once AMD or Nvidia writes one, F@H can give some new core the lowest priority on the GPU.

https://en.wikipedia.org/wiki/Computer_multitasking
Tsar of all the Rushers
I tried to remain childlike, all I achieved was childish.
A friend to those who want no friends
JimboPalmer
 
Posts: 2041
Joined: Mon Feb 16, 2009 5:12 am
Location: Greenwood MS USA

Re: On limiting GPU usage

Postby foldy » Fri Apr 07, 2017 6:56 am

There are tools like MSI Afterburner which can limit GPU power usage to e.g. 50%, so the GPU does not get too hot and loud.
But that does not free GPU resources for other tasks.

I tried a method where FAHCore gets suspended every other second to free GPU resources but that still gives stutter.
foldy
 
Posts: 2014
Joined: Sat Dec 01, 2012 4:43 pm

Re: On limiting GPU usage

Postby antropofob » Fri Apr 07, 2017 1:04 pm

Disabling hardware acceleration in browser helps.
For video playback while folding I recommend MPC-HC in combination with madVR fullscreen exclusive mode.
antropofob
 
Posts: 59
Joined: Mon Aug 22, 2011 9:03 am

Re: On limiting GPU usage

Postby danielocdh » Fri Apr 07, 2017 7:45 pm

bruce wrote:No.

A GPU is either ON or OFF.

The only intermediate setting for a GPU is to set IDLE to TRUE. That will ask FAH to configure the OS so that it treats the GPU in a similar way that the OS treats a screensaver. If the keyboard/mouse are inactive for a while, the GPU starts processing. If you use the keyboard/mouse the OS sets itself to active and GPU processing is suspended. That setting should prevent "screen lag" which is generally a result of FAH using nearly 100% of the GPU's resources when you're not using the computer and suspending processing when you want to see prompt video response.

It's also possible to configure your browser / video player / etc. to use CPU resources instead of GPU resources, which may provide you wit prompt video updates even when the GPU is busy folding.


@bruce, I was thinking on something like this:
Run X amount of calculations, sleep Y amount of time, repeat
X and Y needed for certain GPU load % could be calculated based on an initial GPU benchmark.
I don't have the knowledge to know if this is even possible or will work as expected so I might be wrong, but seemed like a plausible way to implement it.
Edit: I just remembered that I also noticed that the GPU folding process uses a fair amount of CPU, couldn't this CPU use be limited so the GPU use is limited as a side effect?

@foldy As you said, still stutter so no point in doing it for me, thanks.

@antropofob Thanks, I might try those methods.

@JimboPalmer Whoa 3 PCs for such trivial task, I'm glad it's not like that now :)
danielocdh
 
Posts: 4
Joined: Thu Apr 06, 2017 9:56 pm

Re: On limiting GPU usage

Postby bruce » Fri Apr 07, 2017 8:37 pm

Timer-based on/off cycling like you suggest was, in fact, tried. It's too coarse a process and is unacceptable, particularly when you consider the wide range of GPUs that would need to be accommodated. (Read Jimbo Palmer's link to wikipedia and apply the same issues to GPUs) Once submitted, GPU "kernel" (task) cannot be interrupted and processing is FIFO so even though the update from your OS needs close to zero processing, it has to wait. In addition, data must be transferred to/from the GPU over a relatively slow communications (PCIe) path and it's not good for processing to wait for that data transfer.

Someday NVidia, AMD, and friends will work out a better scheme ... but don't hold your breath.
bruce
 
Posts: 20009
Joined: Thu Nov 29, 2007 11:13 pm
Location: So. Cal.

Re: On limiting GPU usage

Postby davidcoton » Fri Apr 07, 2017 9:47 pm

danielocdh wrote:Edit: I just remembered that I also noticed that the GPU folding process uses a fair amount of CPU, couldn't this CPU use be limited so the GPU use is limited as a side effect?

Again, no. The high CPU use is because the (nVidia) driver is written to use a whole core just waiting for the GPU, so it can be serviced very quickly when necessary. nVidia's prime market (gaming) does gain something this way, but the CPU core actually just sits in a wait loop most of the time which is a pure loss for F@H users.
Image
davidcoton
 
Posts: 1102
Joined: Wed Nov 05, 2008 4:19 pm
Location: Cambridge, UK

Re: On limiting GPU usage

Postby 7im » Sat Apr 08, 2017 10:36 pm

Actually, running the FAH CPU client on all CPU cores has been known to slow down the GPU Client slightly. But this is still not the droid you are looking for.
How to provide enough information to get helpful support
Tell me and I forget. Teach me and I remember. Involve me and I learn.
User avatar
7im
 
Posts: 10189
Joined: Thu Nov 29, 2007 5:30 pm
Location: Arizona

Re: On limiting GPU usage

Postby foldy » Mon Apr 10, 2017 8:47 pm

@davidcoton: I think danielocdh is right and you are wrong ;-) As 7im said when another process uses all CPU cores 100% then the FAH GPU core CPU part gets slowed down and as result the GPU usage goes down. Limiting the CPU process by suspending it intermittently also slows down the GPU.

Now to the technical details:
After a GPU kernel run is finished it is waiting for CPU to get the result and post new data. If CPU is busy otherwise or FAH CPU process is suspended then GPU needs to wait longer. When GPU is waiting it means it is idle for some time and that is what we want to reach here because GPU can do other things in that time.

If OpenMM code would introduce an option to reduce CPU usage e.g. by a sleep command (which length or rate the user may configure) then the GPU usage could be reduced. Maybe the FAH GPU Kernel itself can be suspended and resumed easily. In both cases the idea is to alternate between FAH GPU Kernel running and not running to let other GPU tasks have their time. This is the other way round what OpenMM optimization normally tries to do - to increase GPU usage.

Currently there is a discussion on OpenMM how to reduce CPU usage without sacrificing GPU usage.
But there is currently no issue pending to reduce GPU usage configurable by user.
Maybe they can implement that at the same corner by doing more sleeps?

Should I make a github issue about that with usecase folding@home running in parallel with other GPU tasks?
Last edited by foldy on Mon Apr 10, 2017 9:41 pm, edited 3 times in total.
foldy
 
Posts: 2014
Joined: Sat Dec 01, 2012 4:43 pm

Re: On limiting GPU usage

Postby ComputerGenie » Mon Apr 10, 2017 9:06 pm

JimboPalmer wrote:.... (In 1978, when I started using computers I used one computer to word process, one to spell check, and one to print, as CPU sharing had not made it to CP/M microcomputers)...
It makes me feel a little less old knowing I'm not the only one that remembers when 32 kB of memory (RAM with only 1 M back then) was a beast, any upgrades had to be hard soldered in, and the cost of anything useful "started at" ~$2,500 in today's dollars. :P
User avatar
ComputerGenie
 
Posts: 236
Joined: Mon Dec 12, 2016 5:06 am

Re: On limiting GPU usage

Postby foldy » Mon Apr 10, 2017 9:29 pm

This is how alternating suspend and resume of FAH CPU part of GPU core every other second looks like
http://imgur.com/8iqqLwZ
First half of graph shows FAH GPU core running full speed, second half of graph shows FAH GPU core running half speed.
TPF of AMD GPU goes up from 1:36 to 3:00 and TPF of Nvidia GPU from 2:40 to 5:02
So with both GPU types TPF is nearly doubled which is expected.
foldy
 
Posts: 2014
Joined: Sat Dec 01, 2012 4:43 pm

Re: On limiting GPU usage

Postby JimboPalmer » Mon Apr 10, 2017 9:40 pm

Our problem is that F@H can suspend work when it wants to, but that will make video even more jerky, which is not your goal. What will achieve your goal is preemptive multitasking, virtual GPUs machines, or hardware priority queues. Sadly they all need a GPU OS, and that would slow down gaming, so there is no demand for an OS.

I have a Laptop with a low power Intel GPU and a higher performance Nvidia GPU, the driver chooses between them. Sadly no one wrote a Win 10 driver for that, so it is stuck on Win 7.
Having two GPUs, a low power one to run Windows and a high power one for F@H, which would swap roles when you played games, would be ideal. (Actually gamers would resent the 8 shaders out of 3072 still used by F@H and never buy it)

(upgrading my Apple ][ from 32 k to 48k in 1978 cost $320 for 16 k of RAM. The 'ball' printer had a one byte buffer and printed at 13.5 characters a second, so you had to devote an entire microcomputer to feeding that buffer. Larger printer buffers greatly increased background printer speed. And oddly, disk speed.)
JimboPalmer
 
Posts: 2041
Joined: Mon Feb 16, 2009 5:12 am
Location: Greenwood MS USA

Re: On limiting GPU usage

Postby foldy » Mon Apr 10, 2017 9:56 pm

JimboPalmer wrote:Our problem is that F@H can suspend work when it wants to, but that will make video even more jerky, which is not your goal.

Why would it make video even more jerky? The problem with jerky video is the frames cannot be displayed in time. Simplified example: in one second video with 10 frames we see one frame for half a second and the other half second 9 frames. So the latency of the one frame is the problem and it is because FAH GPU Kernel blocks processing the next video frame for half a second in this example and then lets pass the other 9 frames immidiatly during GPU Kernel exchange with CPU.

If FAH GPU Kernel gets suspended maybe 10 times per second that means every 100 ms the GPU has time to do something else, e.g. process a video frame.
So it can process a frame every 100 ms and our 10 video frames distribute evenly over the full second as one frame every 100ms.

As the Operating System like Windows cannot do that a possible solution is FAHCore can do that.

I cannot do that externally in such a 100ms or finer granularity because the FAH GPU Core CPU part then has often enough chances to load the next GPU Kernel.
Edit: I tried with 10ms external sleeps and GPU usage still fluctuates, so maybe ... but I have to test this with lagging video if it makes a difference.

If OpenMM implements that it can say when GPU Kernel finished and if limit is set then just wait 100 ms or finer before starting the next GPU Kernel.
Maybe OpenMM can even suspend and resume the GPU Kernel very fast and the limit is defined by ratio of suspend to run time.
foldy
 
Posts: 2014
Joined: Sat Dec 01, 2012 4:43 pm

Re: On limiting GPU usage

Postby JimboPalmer » Mon Apr 10, 2017 10:45 pm

foldy wrote:
JimboPalmer wrote:Our problem is that F@H can suspend work when it wants to, but that will make video even more jerky, which is not your goal.

Why would it make video even more jerky?
The CPU program, which can see a timer, would have to signal the GPU program via the PCIe bus, the bottleneck of communications.

foldy wrote:As the Operating System like Windows cannot do that a possible solution is FAHCore can do that.
Half assed via the CPU portion signalling the GPU portion, yes. What is needed is an OS for the GPU, which will vary by card. (A raspberry pi zero worth of intelligence would be fine) The GPU does not currently expect more than one program to run, so there is no on board hardware support for what you want.
JimboPalmer
 
Posts: 2041
Joined: Mon Feb 16, 2009 5:12 am
Location: Greenwood MS USA

Next

Return to V7.4.4 Public Release Windows/Linux/MacOS X (deprecated)

Who is online

Users browsing this forum: No registered users and 3 guests

cron