System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64 1809
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary): pip install tensorflow-gpu==2.0.0-alpha0
- TensorFlow version (use command below): v1.12.0-9492-g2c319fb415 2.0.0-alpha0
- Python version: 3.6.7
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version: CUDA 10.0, cudnn-10.0-windows10-x64-v7.5.0.56
- GPU model and memory: GeForce GTX 1070 8GB
Describe the current behavior
Evaluating TF 2.0 keras model allocates twice as much memory as TF 1.x or CNTK.
Describe the expected behavior
Memory usage of TF 2.0 should be same or similar to other libraries, not double.
Code to reproduce the issue
For TF 2.0 or 1.x
import numpy as np
import tensorflow as tf
# tf.config.gpu.set_per_process_memory_growth(True)
size = 28000
inputs = tf.keras.Input((size,), dtype='float32')
outputs = tf.keras.layers.Dense(size)(inputs)
model = tf.keras.models.Model(inputs=inputs, outputs=outputs)
model.predict(np.ones((1, size,), dtype=np.float32))
print('complete')
while True:
pass
For TF 1.x or CNTK with keras
import keras
import numpy as np
size = 28000
inputs = keras.Input((size,), dtype='float32')
outputs = keras.layers.Dense(size)(inputs)
model = keras.models.Model(inputs=inputs, outputs=outputs)
model.predict(np.ones((1, size,), dtype=np.float32))
print('complete')
while True:
pass
With 8GB VRAM GPU, TF 1.x and CNTK works successfully, and TF 2.0 code are failed due to Resource exhausted exception.
System information
Describe the current behavior
Evaluating TF 2.0 keras model allocates twice as much memory as TF 1.x or CNTK.
Describe the expected behavior
Memory usage of TF 2.0 should be same or similar to other libraries, not double.
Code to reproduce the issue
For TF 2.0 or 1.x
For TF 1.x or CNTK with keras
With 8GB VRAM GPU, TF 1.x and CNTK works successfully, and TF 2.0 code are failed due to Resource exhausted exception.