首页 > 解决方案 > Keras 小型网络占用大量 GPU 内存

问题描述

我有一个非常小的神经网络 -

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
scores_input (InputL (None, 2)                 0         
_________________________________________________________________
dense1 (Dense)       (None, 1)                 2         
_________________________________________________________________
bn (BatchNormalizati (None, 1)                 4         
_________________________________________________________________
sigmoid (Activation) (None, 1)                 0         
=================================================================
Total params: 6
Trainable params: 4
Non-trainable params: 2

但是,如 nvidia-smi 所示,它需要大约 1.3 GB 的 gpu 内存

Wed Aug 28 08:41:38 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.130                Driver Version: 384.130                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 960     Off  | 00000000:01:00.0  On |                  N/A |
| 30%   42C    P2    29W / 120W |   1763MiB /  1988MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1258      G   /usr/lib/xorg/Xorg                           251MiB |
|    0      2336      G   compiz                                       231MiB |
|    0     25537      G   .../innereye/qtcreator-4.9.2/bin/qtcreator     2MiB |
|    0     30098      G   ...-token=DA8EE4CD7070EDEBCD3537BAAD982629    37MiB |
|    0     30436      C   python                                      1227MiB |
+-----------------------------------------------------------------------------+

我需要加载另一个(更大的)网络,但它们不适合 GPU 内存。有什么帮助吗?

标签: pythontensorflowkerasout-of-memorygpu

解决方案


推荐阅读