nodejs get gpu usage code example

Example 1: linux check gpu usage

nvidia-smi -l 1

Example 2: javascript get device gpu info

// Create canvas
var canvas = document.createElement("canvas")
var webgl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl")
var debugInfo = webgl.getExtension("webgl_debug_renderer_info")
var gpu = webgl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL)
// We need to use the debugInfo because the webgl
// will return a GPU ID and not the name
// debugInfo extensions unmasks it and returns the GPU Name