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

GPU is enabled but it doesn't change the rendering speed. #127

Open
remyLmnr opened this issue Nov 29, 2022 · 6 comments
Open

GPU is enabled but it doesn't change the rendering speed. #127

remyLmnr opened this issue Nov 29, 2022 · 6 comments

Comments

@remyLmnr
Copy link

Hello,
we are trying to enable the GPU on skia-canvas but we don't see any difference in rendering speed.
We are trying several type of canvas but we don't see any difference.

Context:

  • Ubuntu 20.02
  • Docker
  • Ec2 instance g4dn with Tesla T4 GPU
  • Vulkan 1.2
  • NVIDIA-SMI 470.82.01 Driver Version: 470.82.01 CUDA Version: 11.4

Skia-canvas auto detect the GPU and set .gpu as true.

Vulkaninfo:

Device Groups:
==============
Group 0:
	Properties:
		physicalDevices: count = 1
			Tesla T4 (ID: 0)
		subsetAllocation = 0

	Present Capabilities:
		Tesla T4 (ID: 0):
			Can present images from the following devices: count = 1
				Tesla T4 (ID: 0)
		Present modes: count = 1
			DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR

nvidia-smi:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.01    Driver Version: 470.82.01    CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            Off  | 00000000:00:1E.0 Off |                    0 |
| N/A   32C    P8     9W /  70W |   1348MiB / 15109MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+
  • Are you seeing a difference in term of speed with or without GPU ?
  • Are we missing something ?

Thanks a lot for your work

@omegascorp
Copy link

Facing the same issue tested on 2 servers with GPU, and didn't manage to get any difference.

@JesseRussell411
Copy link

same problem, using the .filter function to apply a blur. Does skia-canvas use the gpu for the blur filter?

@JesseRussell411
Copy link

JesseRussell411 commented Jun 21, 2023

For reference

  • thinkpad t15 gen 2
  • ryzen 7 5850U
  • integrated graphics
  • windows 11
  • skia-canvas version 1.0.1
  • power adapter is plugged in
  • console.log(canvas.gpu) prints true (canvas being the Canvas instance)

The way I'm applying the blur is like this:

context.filter = `blur(5.5px)`;
context.drawImage(canvas, 0, 0, canvas.width, canvas.height)
// canvas is the same canvas that the context belongs to, I'm drawing it onto itself

@JesseRussell411
Copy link

I can add another computer

  • ryzen 5 5500
  • geforce RTX 3060 Ti (standard windows drivers at the moment)
  • windows 11
  • skia-canvas version 1.0.1
  • console.log(canvas.gpu) prints true

same problem

@JesseRussell411
Copy link

Wait, my bad, it does use the gpu but only when I save the canvas to a file. It's still not any faster when using the gpu though, a little slower even. Also I do some manual pixel manipulation with getImageData and putImageData after the blurring and I don't see how that could be cached until the canvas is saved to file. So it kinda still seems like it's not using the gpu for the blur filter.

@mpaperno
Copy link
Contributor

mpaperno commented Aug 29, 2023

I also am having a hard time finding a benefit with GPU rendering enabled.

Not only is it not faster (which is going to depend on the GPU vs. CPU speed I suppose), but it also doesn't use any less CPU time and increases total system memory (RSS) use (and of course also uses VRAM and GPU time). The thread count also doubles, with no apparent benefit.

skia-canvas 1.0.1, NVIDIA RTX 2xxx and 3xxx with latest Studio drivers, Intel i7 and i9 brand CPUs, gen 8+.

(And yea GPU only kicks in when producing the final output, eg. canvas.toBuffer() or canvas.toFile(), etc. (also evident from looking at the Rust code, the drawing surface isn't actually created until Page.encoded_as() is called, which in turn only happens during output).)

Also there is the memory leak I reported earlier, and the strange hang-on-exit issue which is hard to recreate, all related to GPU usage.

In CPU-only mode, SC v1+ in general performs better than the previous versions, which of course is great and makes it worth using just for that. However seems like the GPU feature is maybe not quite ready for production and should be disabled by default.

And I don't mean to disparage, skia-canvas is great and much appreciated! Thanks!

-Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants