diff --git a/docker/config.properties b/docker/config.properties index 227b92667e..0ce8eb8a1a 100644 --- a/docker/config.properties +++ b/docker/config.properties @@ -3,6 +3,7 @@ management_address=http://0.0.0.0:8081 metrics_address=http://0.0.0.0:8082 grpc_inference_address=0.0.0.0 grpc_management_address=0.0.0.0 +enable_envvars_config=true number_of_netty_threads=32 job_queue_size=1000 model_store=/home/model-server/model-store diff --git a/docker/dockerd-entrypoint.sh b/docker/dockerd-entrypoint.sh index 06ecc39f27..f5c828b88a 100755 --- a/docker/dockerd-entrypoint.sh +++ b/docker/dockerd-entrypoint.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" = "serve" ]]; then shift 1 - torchserve --start --ts-config /home/model-server/config.properties --disable-token-auth + torchserve --foreground --ts-config /home/model-server/config.properties --disable-token-auth "$@" else eval "$@" -fi -# prevent docker exit -tail -f /dev/null + # prevent docker exit + tail -f /dev/null +fi diff --git a/examples/image_classifier/mnist/Docker.md b/examples/image_classifier/mnist/Docker.md index e734e831e0..3ec8213c80 100644 --- a/examples/image_classifier/mnist/Docker.md +++ b/examples/image_classifier/mnist/Docker.md @@ -28,7 +28,7 @@ Run the commands given in following steps from the parent directory of the root ### Start a docker container with torchserve ```bash - docker run --rm -it -p 127.0.0.1:8080:8080 -p 127.0.0.1:8081:8081 -p 127.0.0.1:8082:8082 -v $(pwd)/model_store:/home/model-server/model-store pytorch/torchserve:latest-cpu + docker run --rm -it -p 127.0.0.1:8080:8080 -p 127.0.0.1:8081:8081 -p 127.0.0.1:8082:8082 -e TS_ENABLE_MODEL_API=true -v $(pwd)/model_store:/home/model-server/model-store pytorch/torchserve:latest-cpu ``` ### Register the model on TorchServe using the above model archive file @@ -45,6 +45,14 @@ Run the commands given in following steps from the parent directory of the root } ``` + An alternative to manual registration of models is to specify the model names TorchServe should register at startup using the [`load_models`](https://pytorch.org/serve/configuration.html#load-models-at-startup) property. The property can be configured by setting the `TS_LOAD_MODELS=mnist.mar` environment variable (this removes the need for the `TS_ENABLE_MODEL_API` environment variable and the `curl` call above): + + ```bash + docker run --rm -it -p 127.0.0.1:8080:8080 -p 127.0.0.1:8081:8081 -p 127.0.0.1:8082:8082 -e TS_LOAD_MODELS=mnist.mar -v $(pwd)/model_store:/home/model-server/model-store pytorch/torchserve:latest-cpu + ``` + + Note that this approach does not allow specifying the initial number of workers. + ### Run digit recognition inference outside the container ```bash