tensorflow / tensorflow/java

Unintuitive out of memory errors, and odd OOMs

Open
#186 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
928
Forks
227
PR merge metrics
No merged PRs in 30d

Description

I'm experimenting with TensorScope, and thus using large amounts of memory for tensors. However, when I try this, I get odd oom-related errors.

Example (kotlin):

repeat(1000) {
    TFloat32.tensorOf(Shape.of(10000, 10000))
}

gives

2021-01-11 20:36:45.599992: W external/org_tensorflow/tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 400000000 exceeds 10% of free system memory.
2021-01-11 20:36:45.625897: W external/org_tensorflow/tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 400000000 exceeds 10% of free system memory.
2021-01-11 20:36:45.626092: W external/org_tensorflow/tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 400000000 exceeds 10% of free system memory.
2021-01-11 20:36:45.626180: W external/org_tensorflow/tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 400000000 exceeds 10% of free system memory.
2021-01-11 20:36:45.626262: W external/org_tensorflow/tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 400000000 exceeds 10% of free system memory.
Exception in thread "main" java.lang.NullPointerException
	at org.tensorflow.internal.buffer.TensorBuffers.tensorMemory(TensorBuffers.java:180)
	at org.tensorflow.internal.buffer.TensorBuffers.toFloats(TensorBuffers.java:102)
	at org.tensorflow.internal.types.TFloat32Mapper.mapDense(TFloat32Mapper.java:34)
	at org.tensorflow.internal.types.TFloat32Mapper.mapDense(TFloat32Mapper.java:30)
	at org.tensorflow.RawTensor.asTypedTensor(RawTensor.java:215)
	at org.tensorflow.Tensor.of(Tensor.java:90)
	at org.tensorflow.Tensor.of(Tensor.java:63)
	at org.tensorflow.types.TFloat32.tensorOf(TFloat32.java:79)
	at tester.TensorScopeKt.main(TensorScope.kt:8)
	at tester.TensorScopeKt.main(TensorScope.kt)

I'd think this is a fairly straight forward OOM, just without nice error messages, but the used memory in Task Manager (I'm on Windows) barely moves. I do start using heap memory, but it caps 100MB, even with -Xmx6g. Is there some limit on tensor allocations I'm not aware of?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Kotlin example through TFloat32.tensorOf and trace the reported failure at org/tensorflow/internal/buffer/TensorBuffers.java:180. Compare the native allocation warnings with the Java-side exception and define done as reporting allocation failures with an accurate, actionable error instead of the observed NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.