ageron/handson-ml3

[QUESTION] "Installing and Starting TensorFlow Serving" in chapter 19

michabuehlmann opened this issue · 1 comments

I try to use docker with tensorflow on my mac with m1 chip.
But I can't run the tenserflow server.

Do I have to get docker images in the ARM format for my mac? And if yes how do I get these images?

I try the following code from chapter 19:

docker pull tensorflow/serving  # downloads the latest TF Serving image

docker run -it --rm -v "/path/to/my_mnist_model:/models/my_mnist_model" \
    -p 8500:8500 -p 8501:8501 -e MODEL_NAME=my_mnist_model tensorflow/serving

I use "Docker Desktop" for macOS.
I ran the command

docker pull tensorflow/serving  # downloads the latest TF Serving image

I get the images, but in the format "AMD64" as you can see in the following screenshot (from Docker Desktop):
image

When I run the code

docker run -it --rm -v "/Users/michaelbuehlmann/Documents/GitHub/handson-ml31:/models/my_mnist_model" -p 8500:8500 -p 8501:8501 -e MODEL_NAME=my_mnist_model tensorflow/serving:latest

I get the following error message:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
/usr/bin/tf_serving_entrypoint.sh: line 3:     6 Illegal instruction     tensorflow_model_server --port=8500 --rest_api_port=8501 --model_name=${MODEL_NAME} --model_base_path=${MODEL_BASE_PATH}/${MODEL_NAME} "$@"

I tried also the following:

docker run -it --platform linux/arm64 --rm -v "/Users/michaelbuehlmann/Documents/GitHub/handson-ml31/my_mnist_model:/models/my_mnist_model" -p 8500:8500 -p 8501:8501 -e MODEL_NAME=my_mnist_model emacski/tensorflow-serving:latest-linux_arm64

Versions:

  • OS: [MacOSX 14.4.1 Sonoma]
  • Python: [3.11.0]
  • TensorFlow: [2.12.0]
  • Docker Desktop 4.29.0, Engine 26.0.0

I found a solution to my problem with the tensorflow docking image for macOS. I use the image "emacski/tensorflow-serving" with the platform "latest-linux_arm64". So i pull the image with the following command:

docker pull emacski/tensorflow-serving:latest-linux_arm64

And then you can use the image with the command:

docker run -it --rm -v "/Users/michaelbuehlmann/Documents/GitHub/handson-ml31/my_mnist_model:/models/my_mnist_model" -p 8500:8500 -p 8501:8501 -e MODEL_NAME=my_mnist_model emacski/tensorflow-serving:latest-linux_arm64