ageron / handson-ml3

A series of Jupyter notebooks that walk you through the fundamentals of Machine Learning and Deep Learning in Python using Scikit-Learn, Keras and TensorFlow 2.
Apache License 2.0
7.45k stars 3.01k forks source link

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

Open michabuehlmann opened 4 months ago

michabuehlmann commented 4 months ago

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:

michabuehlmann commented 4 months ago

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