question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken tensor on specific GPU

See original GitHub issue

System information

Describe the current behavior With WebGL backend this code returns broken tensor:

  const frameSourceRaw = tf.tensor3d(
    new Int32Array(Array(128 * 224 * 4).fill(225)),
    [128, 224, 4],
    "int32"
  );
  const unstacked = tf.unstack(frameSourceRaw, -1);
  unstacked.forEach((a) => a.print());

is printed:

    [[225, 225, 225, ..., 225, 225, 225],
     [225, 225, 225, ..., 225, 225, 225],
     [225, 225, 225, ..., 225, 225, 225],
     ...,
     [0  , 0  , 0  , ..., 0  , 0  , 0  ],
     [0  , 0  , 0  , ..., 0  , 0  , 0  ],
     [0  , 0  , 0  , ..., 0  , 0  , 0  ]]

while frameSourceRaw is correct. This behavior does not appear only after unstacked operation, but also after other (slice, div). More examples: https://codesandbox.io/s/tfjs-unstack-issue-loz5r?file=/src/index.js

01 tenserflow

Zeros appear after 65536 (2^16) element. With CPU backend or with other GPU or with other array dimensions (eg. 144 * 256) output tensor is correct.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
pyu10055commented, Feb 11, 2021

Looks like the tensor texture might be exceeding the max texture limit 16384, which translate to 16384 * 4 = 65536, since we are packing the tensor into 4 channels of the texture. Can you try to disable the packing and see if the 0 values appears at 1/4 of the size.

tf.env().set('WEBGL_PACK', false)
0reactions
google-ml-butler[bot]commented, Mar 3, 2021

Are you satisfied with the resolution of your issue? Yes No

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set specific gpu in tensorflow? - Stack Overflow
"0" is here the name of the GPU you want to use. You can have the list of the GPU available by typing...
Read more >
How to select GPU programmatically in code #1901 - GitHub
Hi, I found this https://github.com/pytorch/examples/pull/73/files to set an env variable to choose GPU. Is there a way to manually choose ...
Read more >
How to make sure Tensors stay in the same GPU - distributed
Hi everyone! I just have a question regarding how can I make sure that the tensors will stay in the same device.
Read more >
Tips for Optimizing GPU Performance Using Tensor Cores
This is due to how GPUs store and access data. Layers that don't meet this requirement are still accelerated on the GPU. However,...
Read more >
How to create a CPU tensor and GPU tensor in Pytorch
This is achieved by using .device function in which we have to mention the device that we want to use "CPU" or "GPU"....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found