lltcggie / waifu2x-caffe

waifu2xのCaffe版
MIT License
8.04k stars 839 forks source link

Question about GPU usage and VRMs. #104

Open GiRaFa-SM opened 6 years ago

GiRaFa-SM commented 6 years ago

Well, i had an R9 280 and now i'm using an nVidia Quadro 600 on my PC, it upscale images relatively fast (around 15 sec if its a 720p image using 1.6 upscale)... At time when i had my AMD card i've used Waifu2X openCL version for some months but in the beggining of this year it stopped working for no reason, i observed an behaviour on it: The usage and power draw goes to max and back to minimum for every picture, letting it do this for hours on end to thousands of pics is no good.

My question is, how Waifu2X Caffe Works? Do it convert multiple images at once or it does multiple tasks/images at same time (for example, if you start upscaling an image and when 60-80% upscaling is done, it starts upscaling the next one?) If we can like, convert 2 images at same time it would avoid this cycle and not worn out our GPUs, it would work like a game or a video encoding process. If this feature isnt supported, it would be hard to implement a option to "multiple upscaling"?

PS: This program doesnt necessarily needs CUDA 3.0, it supports everything that supports CUDA. Thx dev.

nagadomi commented 6 years ago

waifu2x is an expensive task for GPU memory. In waifu2x-caffe implementation, waifu2x-caffe divides the image into multiple tiles and convert it for each tile. So only one tile can be processed at a time due to the limitation of GPU memory. It is similar to 3DCG renderer. Of course, file IO task and conversion task can be multithreaded, but it does not seem to be implemented.

GiRaFa-SM commented 6 years ago

I know, that feature is called "block-size" right? What i'm asking here is, when the program finish the upscale of all these tiles, (full image) gpu usage lowers to 0 and then go to 100% in a second? Because that's what ruined my video card's VRM, because it worns out this circuitry pretty fast. I havent tried to batch upscale images on it to be honest(W2X Caffe), so i dont really know, but if it works like a encode (continuous task for a certain ammount of time), it shouldn't worn GPUs by constant-extensive usage.

If that's the way this program works (it stops processing the image when you finish that tile, and consequently, the image, and then rising power and gpu usage in a second), it would be possible to implement a setting to start upscaling a block from the next image when the first one is almost finishing?

Ex: Start upscaling img> 90% upscaled>start upscale the second image. To keep the VRM and GPU usage constant.

I think you've answered my question here, but asking won't hurt: "so only one tile can be processed at a time due to the limitation of GPU memory". So anyway it would stop upscaling sometime to start another task if in batch mode i guess.

nagadomi commented 6 years ago

gpu usage lowers to 0 and then go to 100% in a second

It is probably the time it takes for PNG encoding and disk writing. It does not use GPU.

Of course, file IO task and conversion task can be multithreaded, but it does not seem to be implemented.

One problem is that caffe is not thread-safe. There is a known problem that calling caffe's API from other than main thread becomes very slow. It can be solved by restricting the thread that uses the GPU to the main thread, but it is slightly more complicated.

GiRaFa-SM commented 6 years ago

So in short, it's not possible to implement without a heavy tailored hand work, right? What do you recommend? Should I buy a dedicated GPU just for this usage or something else?