Closed yyc-git closed 1 year ago
@yyc-git Thanks for using WebNN Polyfill API and reporting this issue. Could you please share us with your test code and reproduce steps, it would be helpful to find the root cause.
@BruceDai Hello, this is the code, please Download zip: Github
Then, please in the project dir and run the code:
npm install
npm run webpack:dev-server
Then, you can see error in Chrome
if change main.ts code:
let [width, height] = [1280, 720]
to
let [width, height] = [256, 256]
and change input.ts code:
import irradiance_img_path from './dataset/color0.png'
import albedo_img_path from './dataset/albedo0.png'
import depth_img_path from './dataset/depth0.png'
import normal_img_path from './dataset/shading_normal0.png'
to
import irradiance_img_path from './dataset/small/color0.png'
import albedo_img_path from './dataset/small/albedo0.png'
import depth_img_path from './dataset/small/depth0.png'
import normal_img_path from './dataset/small/shading_normal0.png'
Then run by the code:
npm run webpack:dev-server
it's OK and no error
Thanks @yyc-git . I can reproduce this issue and also get this message from console, I'm investigating it.
'Chrome':1 [.WebGL-0000173401D68000] GL_OUT_OF_MEMORY: Error: 0x00000505, in ....\third_party\angle\src\libANGLE\renderer\d3d\d3d11\ResourceManager11.cpp, allocate:496. Internal D3D11 error: HRESULT: 0x8007000E: Error allocating Texture2D
Thanks @qjia7 for pointing the root cause that in WebGL backend it default uses im2col algorithm with flag WEBGL_CONV_IM2COL default being true to speed up convolutions which has memory limitations, so it crashed with large size image. Please change to use experimental conv algorithm by setting flag WEBGL_EXP_CONV being true for this case.
Here's modification, PTAL, thanks.
// in src/wspk.ts
@@ -195,6 +195,7 @@ export let init = async (state, contextOptions) => {
let tf = context.tf
//TODO really use webgpu? or just webgl?
// await tf.setBackend("webgpu")
+ tf.env().set('WEBGL_EXP_CONV', true);
await tf.setBackend("webgl")
await tf.ready()
Please see similar issue https://github.com/tensorflow/tfjs/issues/6678#issuecomment-1195764609.
Thanks @qjia7 for pointing the root cause that in WebGL backend it default uses im2col algorithm with flag WEBGL_CONV_IM2COL default being true to speed up convolutions which has memory limitations, so it crashed with large size image. Please change to use experimental conv algorithm by setting flag WEBGL_EXP_CONV being true for this case.
Here's modification, PTAL, thanks.
// in src/wspk.ts @@ -195,6 +195,7 @@ export let init = async (state, contextOptions) => { let tf = context.tf //TODO really use webgpu? or just webgl? // await tf.setBackend("webgpu") + tf.env().set('WEBGL_EXP_CONV', true); await tf.setBackend("webgl") await tf.ready()
Please see similar issue tensorflow/tfjs#6678 (comment).
Thanks very much, it work and not error! Thanks!
Hello everyone, Thanks for your great work!
My OS
Mac OS Big Sur 10+ Win10
Description
set backend to webgl
When I use input with 256*258 size image and inference, it's OK and no error
But when I use input with 1280*720 size image and inference, it error, error info is: