Alexandre Vieira
Alexandre Vieira

Reputation: 168

TensorFlow CUDA_ERROR_OUT_OF_MEMORY

I'm trying to build a large CNN in TensorFlow, and intend to run it on a multi-GPU system. I've adopted a "tower" system and split batches for both GPUs, while keeping the variables and other computations on the CPU. My system has 32GB of memory, but when I run my code I get the error:

E tensorflow/stream_executor/cuda/cuda_driver.cc:924] failed to alloc 17179869184 bytes on host: CUDA_ERROR_OUT_OF_MEMORY
W ./tensorflow/core/common_runtime/gpu/pool_allocator.h:195] could not allocate pinned host memory of size: 17179869184
Killed

I've seen that the code works (though very very slowly) if I hide CUDA devices to TensorFlow, and thus it doesn't use cudaMallocHost()...

Thank you for your time.

Upvotes: 13

Views: 17191

Answers (2)

Prasang Ramnani
Prasang Ramnani

Reputation: 11

reduce the batch_size in your code to 100 then it'll work

Upvotes: 0

Ali
Ali

Reputation: 974

There are some options:

1- reduce your batch size

2- use memory growing:

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

3- don't allocate whole of your GPU memory(only 90%):

config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.9
session = tf.Session(config=config, ...)

Upvotes: 13

Related Questions