javascript - Tensorflow js:您的应用程序包含足够小的操作,可以在 CPU 后端执行,但是找不到 CPU 后端
问题描述
我在使用带有 webgl 后端的 tfjs 的浏览器中使用 handpose tensorflow 模型进行手部检测。但是,我在控制台中看到警告
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.
如果我尝试将它添加到我的项目中,我会看到很多关于该 CPU 后端已注册的警告。
有没有办法在 tfjs 中同时使用 CPU 和 GPU(webgl)?
解决方案
默认情况下,Tensorflow JS 在 CPU 上进行一些推理(前向传播而不是反向传播),因为一些 CPU 具有加速矩阵乘法的向量算术单元。
您可以检查tf.ENV.flags
变量以查看 tfjs 默认设置的各种状态变量。其中之一是WEBGL_CPU_FORWARD
标志,您可以在控制台或 javascript 函数中将其设置为 true。
tf.ENV.set("WEBGL_CPU_FORWARD", true)
script
这应该会激活 CPU 后端,而无需在标签中再次导入它。或者,您可以忽略警告,因为它们根本不会影响您的程序。
推荐阅读
- lisp - 如何在 Woo 中读取 http 正文
- postgresql - 错误估计生成长期运行的查询计划
- node.js - 在 URL 中输入表情符号
- arrays - 将按钮添加到滚动视图中的按钮数组
- flowtype - Flowtype - 是否有任何理由不将所有 node_modules 放在 [declarations] 中?
- wordpress - Wordpress 仪表板 html 页面
- c++ - C++ CIMG突然停止打开显示
- java - 无法将 java.util.Date 值与 MySQL 日期时间列值进行比较
- python - 具有唯一约束的 Django 添加到购物车功能失败
- django - 找不到路径 todolist_app / index.html 嘿,有人知道吗?#TemplateDoesNotExist