当副本包含空格时,如何使用bazel在docker build图像上交叉编译tensorflow-serving

в.тралала

背景信息

我想在不支持标准tensorflow构建中使用的现代cpu指令的某些较旧的机器(目标系统)上运行tensorflow-serving。我使用这些说明通过docker安装tf-serving。但是我在github上遇到了Tensorflow Serving Illegal Instruction core dumped与此类似的错误建议的解决方案是使用一个码头工人集结图像编译它描述了我的目标系统上的二进制这里

由于这部分与复制我的问题有关,因此我将在此处复制相关命令:

git clone https://github.com/tensorflow/serving
cd serving
docker build --pull -t $USER/tensorflow-serving-devel -f tensorflow_serving/tools/docker/Dockerfile.devel .

这将-march=native在速度较慢的目标计算机上的docker容器中将带有标志的二进制文件编译出来并工作。


目标系统信息

但是,在我的旧计算机上,编译将永远耗时,我想使用其他功能更强大的PC对二进制文件进行交叉编译。我使用了此答案中提供的命令来找出目标系统所需的编译标志,以复制构建标志-march=native,该标志是上述过程中隐式使用的默认标志。

gcc -### -E - -march=native 2>&1 | sed -r '/cc1/!d;s/(")|(^.* - )//g'

给了我以下标志:

-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2

请特别注意末尾的跟随标志,其中包含空格:

 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048

我可以在docker构建过程中通过build参数提供这些标志TF_SERVING_BUILD_OPTIONS,如此处的文档所述

然后,该字符串用于运行bazel构建,可以在 Dockerfile.devel

因此,我从上方获取所有标志并将其放在--copt=最前面,并将结果字符串放入变量中TF_SERVING_BUILD_OPTIONS这是我的总命令,包括末尾带有空格的副本:

docker build --pull \
    --build-arg TF_SERVING_BUILD_OPTIONS="--copt=-mmmx --copt=-mno-3dnow --copt=-msse --copt=-msse2 --copt=-msse3 --copt=-mssse3 --copt=-mno-sse4a --copt=-mcx16 --copt=-msahf --copt=-mno-movbe --copt=-mno-aes --copt=-mno-sha --copt=-mno-pclmul --copt=-mno-popcnt --copt=-mno-abm --copt=-mno-lwp --copt=-mno-fma --copt=-mno-fma4 --copt=-mno-xop --copt=-mno-bmi --copt=-mno-bmi2 --copt=-mno-tbm --copt=-mno-avx --copt=-mno-avx2 --copt=-mno-sse4.2 --copt=-mno-sse4.1 --copt=-mno-lzcnt --copt=-mno-rtm --copt=-mno-hle --copt=-mno-rdrnd --copt=-mno-f16c --copt=-mno-fsgsbase --copt=-mno-rdseed --copt=-mno-prfchw --copt=-mno-adx --copt=-mfxsr --copt=-mno-xsave --copt=-mno-xsaveopt --copt=-mno-avx512f --copt=-mno-avx512er --copt=-mno-avx512cd --copt=-mno-avx512pf --copt=-mno-prefetchwt1 --copt=-mno-clflushopt --copt=-mno-xsavec --copt=-mno-xsaves --copt=-mno-avx512dq --copt=-mno-avx512bw --copt=-mno-avx512vl --copt=-mno-avx512ifma --copt=-mno-avx512vbmi --copt=-mno-clwb --copt=-mno-mwaitx --copt=-mno-clzero --copt=--param l1-cache-size=32 --copt=--param l1-cache-line-size=64 --copt=--param l2-cache-size=2048 --copt=-mtune=core2" \
    -t $USER/tensorflow/serving-devel \
    -f tensorflow_serving/tools/docker/Dockerfile.devel .

问题

但是,bazel抱怨如下,这可能是由于它们之间的空间所致,--paraml1-cache-size=32这是提供给bazel build调用的C编译器的一个选项。

ERROR: Skipping 'l1-cache-line-size=64': couldn't determine target from filename 'l1-cache-line-size=64'
ERROR: couldn't determine target from filename 'l1-cache-line-size=64'
INFO: Elapsed time: 20.233s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
The command '/bin/sh -c bazel build --color=yes --curses=yes     ${TF_SERVING_BAZEL_OPTIONS}     --verbose_failures     --output_filter=DONT_MATCH_ANYTHING     ${TF_SERVING_BUILD_OPTIONS}     tensorflow_serving/model_servers:tensorflow_model_server &&     cp bazel-bin/tensorflow_serving/model_servers/tensorflow_model_server     /usr/local/bin/' returned a non-zero code: 1

我尝试了什么

  1. 我尝试在最后一个标志中转义空格字符:
TF_SERVING_BUILD_OPTIONS="--copt=-mmmx ... --copt=--param\ l1-cache-size=32 --copt=--param\ l1-cache-line-size=64 --copt=--param\ l2-cache-size=2048 --copt=-mtune=core2 "

但是bazel仍然抱怨与上面相同的错误消息。

  1. 我尝试将命令括在双引号或单引号中:
TF_SERVING_BUILD_OPTIONS="--copt=-mmmx ... --copt=\"--param l1-cache-size=32\" --copt=\"--param l1-cache-line-size=64\" --copt=\"--param l2-cache-size=2048\" --copt=-mtune=core2 "

还会出现与以前相同的错误。

  1. 我尝试使用内部双引号,coptsTF_SERVING_BUILD_OPTIONS使用外部单引号将换行,但存在相同的错误。

  2. 我尝试使用来转义双引号\x22与以前类似的错误。这次表明目标格式不正确ERROR: Skipping 'l1-cache-size=32\x22': Bad target pattern...

  3. 我尝试使用以下命令转义空格字符\40

TF_SERVING_BUILD_OPTIONS="--copt=-mmmx ... --copt=--param\40l1-cache-size=32 --copt=--param\40l1-cache-line-size=64 --copt=--param\40l2-cache-size=2048 --copt=-mtune=core2 "

这次bazel并没有抱怨,因为copt的参数是一个没有正常空格的字符串。但是,由于我收到以下错误,参数被错误地传递给gcc:

ERROR: /root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/external/grpc/BUILD:692:1: C++ compilation of rule '@grpc//:grpc_base_c' failed (Exit 1): gcc failed: error executing command 
  (cd /root/.cache/bazel/_bazel_root/e53bbb0b0da4e26d24b415310219b953/execroot/tf_serving && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/usr/bin/python \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/k8-opt/bin/external/grpc/_objs/grpc_base_c/endpoint_pair_uv.d '-frandom-seed=bazel-out/k8-opt/bin/external/grpc/_objs/grpc_base_c/endpoint_pair_uv.o' '-DGRPC_ARES=0' -iquote external/grpc -iquote bazel-out/k8-opt/genfiles/external/grpc -iquote bazel-out/k8-opt/bin/external/grpc -iquote external/zlib_archive -iquote bazel-out/k8-opt/genfiles/external/zlib_archive -iquote bazel-out/k8-opt/bin/external/zlib_archive -isystem external/grpc/include -isystem bazel-out/k8-opt/genfiles/external/grpc/include -isystem bazel-out/k8-opt/bin/external/grpc/include -isystem external/zlib_archive -isystem bazel-out/k8-opt/genfiles/external/zlib_archive -isystem bazel-out/k8-opt/bin/external/zlib_archive -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-mwaitx -mno-clzero '--param\40l1-cache-size=32' '--param\40l1-cache-line-size=64' '--param\40l2-cache-size=2048' '-mtune=core2' '-std=c++14' '-D_GLIBCXX_USE_CXX11_ABI=0' -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/grpc/src/core/lib/iomgr/endpoint_pair_uv.cc -o bazel-out/k8-opt/bin/external/grpc/_objs/grpc_base_c/endpoint_pair_uv.o)
Execution platform: @bazel_tools//platforms:host_platform
gcc: error: unrecognized command line option '--param\40l1-cache-size=32'
gcc: error: unrecognized command line option '--param\40l1-cache-line-size=64'
gcc: error: unrecognized command line option '--param\40l2-cache-size=2048'
Target //tensorflow_serving/model_servers:tensorflow_model_server failed to build

看来这与github上的以下问题有关

  1. 我尝试了不带空格的标志的编译,并最终完成了罚款,这进一步加强了以下假设:错误是由于从bazel处理不正确的空格引起的。

我该如何解决这个问题?

w

我想在不支持标准tensorflow构建中使用的现代cpu指令的某些较旧的机器(目标系统)上运行tensorflow-serving。我使用这些说明通过docker安装tf-serving。但是我遇到了错误的Tensorflow Serving Illegal Instruction Core类似于github上的一个错误转储...

-march=native如果我没记错的话,Bazel和TensorFlow默认在其构建标志中使用。

您应该省略该标志,或者指定更合适的标志,例如-march=sse4.2

-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf
-mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma
-mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2
-mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase
-mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f
-mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec
-mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi
-mno-clwb -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32
--param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2

您的转储显示-mno-sse4.1我相信这意味着您可以使用以下内容并完成此操作。

-msse2 -msse3 -mssse3

x86_64将SSE2作为核心指令集的一部分,因此它暗示了MMX和SSE。

认为您不应该使用-march=core2-mtune=core2因为Core2意味着您拥有SSE4.1(早期的iCore cpus)或SSE4.2(后来的iCore cpus)。

x86_64选项上的GCC手册页上,这对我来说可疑/错误:

核心2

具有64位扩展,MMX,SSE,SSE2,SSE3和SSSE3指令集的Intel Core2 CPU。

我相当确定Core2比SSSE3更强大。我保留了几台Core2机器进行测试,它们具有SSE4.1和SSE4.2。(我相信有人有CRC指令,那就是SSE4.2 ISA)。

我可能对GCC选项页有误,但对我来说似乎很可疑。


Tensorflow服务非法指令核心已转储

什么是非法指示?


gcc-### -E--march = native 2>&1 | sed -r'/cc1/!d;s/(")|(^.*-)// g'

只是另一种观点,但是我发现类似的东西更有用。在Skylake机器上:

$ gcc -march=native -dM -E - </dev/null | grep -E 'SSE|CRC|AES|PCL|RDRND|RDSEED|AVX' | sort
#define __AES__ 1
#define __AVX__ 1
#define __AVX2__ 1
#define __PCLMUL__ 1
#define __RDRND__ 1
#define __RDSEED__ 1
#define __SSE__ 1
#define __SSE2__ 1
#define __SSE2_MATH__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE4_2__ 1
#define __SSE_MATH__ 1
#define __SSSE3__ 1

从预处理器转储我知道我可以使用-msse2-msse3-mssse3-msse4.1-msse4.2-mavx-mavx2

在Core2机器上:

$ gcc -march=native -dM -E - </dev/null | grep -E 'SSE|CRC|AES|PCL|RDRND|RDSEED|AVX' | sort
#define __SSE__ 1
#define __SSE2__ 1
#define __SSE2_MATH__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE_MATH__ 1
#define __SSSE3__ 1

从预处理器转储我知道我可以使用-msse2-msse3-mssse3-msse4.1

从另一台Core2机器上:

$ gcc -march=native -dM -E - </dev/null | grep -E 'SSE|CRC|AES|PCL|RDRND|RDSEED|AVX' | sort
#define __SSE2_MATH__ 1
#define __SSE2__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE_MATH__ 1
#define __SSE__ 1
#define __SSSE3__ 1

从预处理器转储我知道我可以使用-msse2-msse3-mssse3-msse4.1


尽管杂乱无章,但对我来说这似乎是可疑的。什么文件名?该选项指定高速缓存行大小。您是否缺少--该选项?

ERROR: Skipping 'l1-cache-line-size=64': couldn't determine target from filename 'l1-cache-line-size=64'
ERROR: couldn't determine target from filename 'l1-cache-line-size=64'

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

docker如何运行tensorflow-serving及其模型?

来自分类Dev

如何使用 REST API 端点启动 TensorFlow Serving ModelServer

来自分类Dev

在MAC上交叉编译C时出现libcurl问题

来自分类Dev

在CMake上交叉编译到OSX时设置SDK

来自分类Dev

如何在Ubuntu for Win32上交叉编译Clang?

来自分类Dev

如何使用python将请求发送到tensorflow服务器(tensorflow-serving)?

来自分类Dev

为 TensorFlow Serving 导出 textsum 模型时出现错误“str”对象没有属性“dtype”

来自分类Dev

在Musl 1.2.0上交叉编译rust项目时,“对__stat_time64的未定义引用”

来自分类Dev

调整使用get_serving_url直接从GAE中的GCS直接提供的图像的大小?

来自分类Dev

调整使用get_serving_url直接从GAE中的GCS直接提供的图像的大小?

来自分类Dev

如何在x64主机上交叉编译AArch64的LLVM / Clang?

来自分类Dev

如何在ipad mini 3上交叉编译iOS8.x的clang / llvm 3.7.0?

来自分类Dev

DNNClassifier 模型到 TensorFlow Serving 模型

来自分类Dev

如何为在x86主机上交叉编译的手臂目标项目安装依赖项

来自分类Dev

在ARM上交叉编译ImageMagick

来自分类Dev

GAE Python:如何使用delete_serving_url

来自分类Dev

GAE Python:如何使用delete_serving_url

来自分类Dev

向Tensorflow Serving邮递员请求预测REST API

来自分类Dev

为什么这个TensorFlow Serving gRPC调用会挂起?

来自分类Dev

使用Build.scala进行交叉编译时,如何为每个Scala版本设置不同的scalacOptions?

来自分类Dev

在ubuntu上交叉编译Boost 1.57.0 for arm

来自分类Dev

交叉编译时如何使用外部库?

来自分类Dev

如何交叉编译Python?

来自分类Dev

将 class = tensorflow_serving.apis.classification_pb2.ClassificationResponse 转换为 json

来自分类Dev

与Bazel交叉编译时,系统标题的“缺少依赖项声明”

来自分类Dev

Knative Serving的Activator如何拦截按比例缩小的修订版本的请求?

来自分类Dev

使用Yahoo Cloud Serving Benchmark生成大量数据和速度数据

来自分类Dev

使用OpenWRT交叉编译OpenCV时出错

来自分类Dev

使用OpenWRT交叉编译OpenCV时出错

Related 相关文章

  1. 1

    docker如何运行tensorflow-serving及其模型?

  2. 2

    如何使用 REST API 端点启动 TensorFlow Serving ModelServer

  3. 3

    在MAC上交叉编译C时出现libcurl问题

  4. 4

    在CMake上交叉编译到OSX时设置SDK

  5. 5

    如何在Ubuntu for Win32上交叉编译Clang?

  6. 6

    如何使用python将请求发送到tensorflow服务器(tensorflow-serving)?

  7. 7

    为 TensorFlow Serving 导出 textsum 模型时出现错误“str”对象没有属性“dtype”

  8. 8

    在Musl 1.2.0上交叉编译rust项目时,“对__stat_time64的未定义引用”

  9. 9

    调整使用get_serving_url直接从GAE中的GCS直接提供的图像的大小?

  10. 10

    调整使用get_serving_url直接从GAE中的GCS直接提供的图像的大小?

  11. 11

    如何在x64主机上交叉编译AArch64的LLVM / Clang?

  12. 12

    如何在ipad mini 3上交叉编译iOS8.x的clang / llvm 3.7.0?

  13. 13

    DNNClassifier 模型到 TensorFlow Serving 模型

  14. 14

    如何为在x86主机上交叉编译的手臂目标项目安装依赖项

  15. 15

    在ARM上交叉编译ImageMagick

  16. 16

    GAE Python:如何使用delete_serving_url

  17. 17

    GAE Python:如何使用delete_serving_url

  18. 18

    向Tensorflow Serving邮递员请求预测REST API

  19. 19

    为什么这个TensorFlow Serving gRPC调用会挂起?

  20. 20

    使用Build.scala进行交叉编译时,如何为每个Scala版本设置不同的scalacOptions?

  21. 21

    在ubuntu上交叉编译Boost 1.57.0 for arm

  22. 22

    交叉编译时如何使用外部库?

  23. 23

    如何交叉编译Python?

  24. 24

    将 class = tensorflow_serving.apis.classification_pb2.ClassificationResponse 转换为 json

  25. 25

    与Bazel交叉编译时,系统标题的“缺少依赖项声明”

  26. 26

    Knative Serving的Activator如何拦截按比例缩小的修订版本的请求?

  27. 27

    使用Yahoo Cloud Serving Benchmark生成大量数据和速度数据

  28. 28

    使用OpenWRT交叉编译OpenCV时出错

  29. 29

    使用OpenWRT交叉编译OpenCV时出错

热门标签

归档