Skip to content

Troubleshooting

Mohamed E. Masoud edited this page Jan 22, 2024 · 10 revisions

Miscellaneous:

Call script lib from console:

var script = document.createElement('script');

script.type = 'text/javascript';

script.src = 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js';

document.head.appendChild(script);

Check whether the device supports 32 bit textures:

tf.ENV.getBool('WEBGL_RENDER_FLOAT32_CAPABLE'): false means the device only supports 16 bit floating point textures.

tf.ENV.getBool('WEBGL_RENDER_FLOAT32_ENABLED'): true means tfjs is currently using 32 bit textures.

tf.ENV.get('WEBGL_FORCE_F16_TEXTURES'): false means 16 bit textures not currently used

Also

tf.ENV.getBool('WEBGL_FORCE_F16_TEXTURES')

To set F16

tf.env().set('WEBGL_FORCE_F16_TEXTURES', true);


const nodeGles = require('node-gles');

const nodeGl = nodeGles.binding.createWebGLRenderingContext();

// TODO(kreeger): These are hard-coded GL integration flags. These need to be // updated to ensure they work on all systems with proper exception reporting.

tf.env().set('WEBGL_VERSION', 2);

tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);

tf.env().set('WEBGL_DOWNLOAD_FLOAT_ENABLED', true);

tf.env().set('WEBGL_FENCE_API_ENABLED', true); // OpenGL ES 3.0 and higher..

tf.env().set( 'WEBGL_MAX_TEXTURE_SIZE', nodeGl.getParameter(nodeGl.MAX_TEXTURE_SIZE));

tf.webgl.setWebGLContext(2, nodeGl);


Whether rendering to float32 textures is enabled. If disabled, renders to float16 textures.

ENV.registerFlag('WEBGL_RENDER_FLOAT32_ENABLED', () => {

return ENV.getBool('WEBGL_FORCE_F16_TEXTURES') ? false : ENV.getBool('WEBGL_RENDER_FLOAT32_CAPABLE');

});


Enforce use of half precision textures if available on the platform.

export function forceHalfFloat(): void {

env().set('WEBGL_FORCE_F16_TEXTURES', true);

}

OR

tf.env().set('WEBGL_FORCE_F16_TEXTURES', true);


tf.env().getNumber('WEBGL_VERSION')

returns 1 or 2

Clone this wiki locally