在 OSX 上使用 Docker 时出现 Tensorflow Serving 编译错误

2024-04-06

我尝试使用 Docker 在 OSX El Capitan 上安装 TensorFlow 服务,但始终遇到错误。这是我正在遵循的教程:

https://tensorflow.github.io/serving/docker.html https://tensorflow.github.io/serving/docker.html

这是导致错误的命令:

bazel test tensorflow_serving/...

这是我收到的错误:

for (int i = 0; i < suffix.size(); ++i) {
                                   ^
ERROR: /root/.cache/bazel/_bazel_root/f8d1071c69ea316497c31e40fe01608c/external/tf/tensorflow/core/kernels/BUILD:212:1: C++ compilation of rule '@tf//tensorflow/core/kernels:mirror_pad_op' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -iquote external/tf -iquote ... (remaining 65 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 4.
gcc: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.

解决了!看起来问题在于虚拟机内存不足。

这是我修复它的方法:

1)创建机器时,确保它有更多的内存(我的只有1GB)。以下是创建 4GB docker 机器的方法:

docker-machine create -d virtualbox --virtualbox-memory 4096 default

2) 运行 bazel 命令时传递一个限制要使用的内存量的参数。这里我仅使用 2GB 运行命令:

bazel build -c opt --copt=-mavx --verbose_failures --local_resources 2048,2.0,1.0 -j 1 //tensorflow_serving/example:mnist_export 

原来的命令是:

bazel build //tensorflow_serving/example:mnist_export
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 OSX 上使用 Docker 时出现 Tensorflow Serving 编译错误 的相关文章

随机推荐