关于Rapberry Pi的CNN模型

时间:2018-05-16 09:05:26

标签: python tensorflow machine-learning raspberry-pi keras

我正在研究一项涉及Raspberry pi 3B青光眼检测的项目。该模型在我的笔记本电脑上训练,大约400mb“.h5”文件。我正在尝试使用keras将模型加载到pi上pi似乎加载了其他较小的模型,但是出现了我的错误:

2018-05-15 18:07:04.117054: W tensorflow/core/framework/allocator.cc:101] Allocation of 134217728 exceeds 10% of system memory.
2018-05-15 18:07:05.052281: W tensorflow/core/framework/allocator.cc:101] Allocation of 134217728 exceeds 10% of system memory.
2018-05-15 18:07:05.513437: W tensorflow/core/framework/allocator.cc:101] Allocation of 134217728 exceeds 10% of system memory.
2018-05-15 18:07:06.191609: W tensorflow/core/framework/allocator.cc:101] Allocation of 134217728 exceeds 10% of system memory.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1322, in _do_call
    return fn(*args)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1307, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1409, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InternalError: Could not allocate ndarray

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 273, in load_model
    topology.load_weights_from_hdf5_group(f['model_weights'], model.layers)
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 3393, in load_weights_from_hdf5_group
    K.batch_set_value(weight_value_tuples)
  File "/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py", line 2377, in batch_set_value
    get_session().run(assign_ops, feed_dict=feed_dict)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 900, in run
    run_metadata_ptr)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1135, in _run
    feed_dict_tensor, options, run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1316, in _do_run
    run_metadata)
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/client/session.py", line 1335, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InternalError: Could not allocate ndarray

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

构建足够大的模型,最终它不适合1Gb Pi。你在那里。

您有三种选择:

  1. 构建较小的模型,或
  2. 查看是否有可以关闭的非必要服务(例如,如果您没有使用显示器运行,请尝试安装Raspian服务器)或
  3. 升级到具有更多RAM的内容。例如,华硕Tinker或Oroid-2板,与Pi相同,但有2Gb RAM。