Illegal Instruction when trying to build tensorflow serving 1.15
Expected output from development image
$ docker pull tensorflow/serving:1.15.0-devel
$ docker run --rm -it tensorflow/serving:1.15.0-devel /bin/bash
root@22718405a907:/tensorflow-serving# /usr/local/bin/tensorflow_model_server
Failed to start server. Error: Invalid argument: Both server_options.model_base_path and server_options.model_config_file are empty!
Output when I build from source using the Dockerfile.devel file
$ docker run --rm -it my-tf-serving-image:1.15.0 /bin/bash
root@514ee9369ee0:/tensorflow-serving# /usr/local/bin/tensorflow_model_server
Illegal instruction
Output when I build from source using the Dockerfile.devel file and run through gdb
$ docker run --rm -it my-tf-serving-image:1.15.0 /bin/bash
root@514ee9369ee0:/tensorflow-serving# gdb /usr/local/bin/tensorflow_model_server
Reading symbols from /usr/local/bin/tensorflow_model_server...done.
(gdb)
(gdb) break main
Breakpoint 1 at 0x47d660: file tensorflow_serving/model_servers/main.cc, line 56.
(gdb) run
Starting program: /usr/local/bin/tensorflow_model_server
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
google::protobuf::internal::ShutdownData::get () at external/com_google_protobuf/src/google/protobuf/stubs/common.cc:331
331 external/com_google_protobuf/src/google/protobuf/stubs/common.cc: No such file or directory.
When I pull the development image, everything works as expected (the server tries to start but I didn't give it a model). When I copy the Dockerfile.devel and try to build r1.15 from source, I get the issue described above. All I have changed in the Dockerfile is master to r1.15. Is there a dependency I'm missing in order to build this image?
Env info
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS
$ gcc -v
gcc version 7.3.0 (GCC)
$ docker -v
Docker version 19.03.4, build 9013bf583a
@gobrewers14, Can you please let us know if there is any specific reason why you want to install Tensorflow Serving from Source. Because, the recommended way to install it is through Docker. Thanks!
@rmothukuru Yes, we (my place of employment) need tf_sentencepiece at inference time as well as we have a collection of custom tensorflow ops (in c++) that need to be served. When combining all of these into the Dockerfile serving provides, and building, we received the above error. Assuming it had to do with something we'd added, we stripped out all our custom build instructions and just tried to build the provided Dockerfile and still got the same error.
Were you able to reproduce?
Any update on this? This is a pretty big roadblock for our production pipeline. A "we are able to reproduce this and are working on it on our side" or a "no, we cant reproduce this, this is an issue on your side" would be extremely helpful.
Sorry for the late response. All of our team were out in an internal summit. We're taking a look now.
So I'm not able to reproduce. The steps I tried are:
$ git clone https://github.com/tensorflow/serving.git /tmp/tfserv
$ cd /tmp/tfserv
Then I edited tensorflow_serving/tools/docker/Dockerfile.devel to change this line from master to r1.15.
$ docker build --pull --build_arg TF_SERVING_BUILD_OPTIONS="--local_ram_resources=2048" -t $USER/tensorflow-serving-devel -f tensorflow_serving/tools/docker/Dockerfile.devel .
$ docker run --rm -it $USER/tensorflow-serving-devel:latest /bin/bash
root@5dee48e34830:/tensorflow-serving# /usr/local/bin/tensorflow_model_server
Failed to start server. Error: Invalid argument: Both server_options.model_base_path and server_options.model_config_file are empty!
Are these different from your commands ? If so, I can try those and get back to you.
@vinuraja Thanks for the reply
The only difference in our commands is --build_arg TF_SERVING_BUILD_OPTIONS="--local_ram_resources=2048". When I add this the build completes and I don't receive an illegal instruction error. But when you set this command at build time, isn't it overriding ARG TF_SERVING_BUILD_OPTIONS="--config=nativeopt" on line 84 of Dockerfile.devel?
If I set them manually
# ...
# stuff
RUN bazel build \
--config=nativeopt \
--local_ram_resources=2048 \
# ...
# build commands
I get the same issue described above. As in, the presence of the flag --config=nativeopt seems to be causing the issue.
Ah I see. I did the same, with the nativeopt flag and it still works for me. Steps:
$ docker build --pull --build-arg TF_SERVING_BUILD_OPTIONS="--config=nativeopt --local_ram_resources=2048" -t $USER/tensorflow-serving-devel-nativeopt -f tensorflow_serving/tools/docker/Dockerfile.devel .
$ docker run --rm -it $USER/tensorflow-serving-devel-nativeopt:latest /bin/bash
root@0cf11bf8cc5a:/tensorflow-serving# /usr/local/bin/tensorflow_model_server
Failed to start server. Error: Invalid argument: Both server_options.model_base_path and server_options.model_config_file are empty!
Some additional information that may be relevant for reproduction.
- this is being built on an amazon instance with 96 cores to reduce build time
- when I run the image on that machine after building, it works.
- when I push the image to our internal ecr repo and then pull it to any other machine (local mac osx, google cloud or aws instance, etc ...) it throws the above illegal instruction error.
That makes sense. The --config=nativeopt is supposed to setup compilation flags according to the machine being built on. If you end up running on a different machine, you'll have to make sure that that machine has the same capabilities as the one being built on.
I would suggest figuring out the capabilities of the machine(s) you're eventually going to run on, and explicitly compiling for those. Or building directly on the final machine with --config=nativeopt.
Interesting. That narrows down my point of confusion.
Why is the image you've provided (tensorflow/serving:1.15.0-devel) able to run on any machine/environment successfully even though it has the --config=nativeopt flag set in the Dockerfile.devel from which it is constructed?
That's a good question. I think the machine we use to build that image might have the lowest common denominator of capabilities. So the image is able to run in most other machines.
I see. Okay. I guess I'll just build it without the flag. Closing for now. Thanks for the discussion.