wwilkowski
wwilkowski

Reputation: 361

Tensorflow js: Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found

I use handpose tensorflow model for hand detection in browser using tfjs with webgl backend. However, i see warning in console Your application contains ops that are small enough to be executed on the CPU backend, however the CPU backend cannot be found. Consider importing the CPU backend (@tensorflow/tfjs-backend-cpu) for better performance.

If i try to add it to my project, I see a lot of warnings about that CPU backend is already registered.

Is there any way to use CPU and GPU (webgl) together in tfjs?

Upvotes: 1

Views: 860

Answers (1)

Andy K
Andy K

Reputation: 191

By default, Tensorflow JS does some of the inference (forward propagation as opposed to backprop) on the CPU, since some CPUs have vector arithmetic units that speed up matrix multiplication.

You can check the tf.ENV.flags variable to see the various state variables that tfjs sets by default. One of them is the WEBGL_CPU_FORWARD flag, which you can set to true like this in the console or in a javascript function.

tf.ENV.set("WEBGL_CPU_FORWARD", true)

This should activate the CPU backend without you having to import it again in a script tag. Or, you can just ignore the warnings since they don't impact your program at all.

Upvotes: 1

Related Questions