【发布时间】:2019-04-24 07:44:30
【问题描述】:
我想使用 Keras 在 2 Gb GPU 上推断 3584x2796 大小的 2D 图像。是否可以?网络架构是一个 Unet。
在推理过程中总是出现内存不足错误。即使是卷积,也只针对第一层失败。 Keras 似乎没有针对大图像卷积进行优化。即使是下面的网络在 2 Gb GPU 上进行推理时也会失败。
Layer (type) Output Shape Param #
=================================================================
input_3 (InputLayer) (None, 3584, 2796, 1) 0
_________________________________________________________________
conv2d_4 (Conv2D) (None, 3584, 2796, 32) 80
_________________________________________________________________
conv2d_5 (Conv2D) (None, 3584, 2796, 32) 584
_________________________________________________________________
instance_normalization_3 (In (None, 3584, 2796, 32) 2
_________________________________________________________________
activation_3 (Activation) (None, 3584, 2796, 32) 0
=================================================================
Total params: 666
Trainable params: 666
Non-trainable params: 0
我得到以下错误:
OOM when allocating tensor with shape[1,32,3584,2796] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
[[{{node conv2d_2/convolution}} = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](conv2d_2/convolution-0-TransposeNHWCToNCHW-LayoutOptimizer, conv2d_2/kernel/read)]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
[[{{node activation_2/Relu/_11}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_47_activation_2/Relu", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
【问题讨论】:
标签: keras