appengine-custom-runtimes-samples
appengine-custom-runtimes-samples copied to clipboard
App Engine Flex + Docker + R +Plumber does not work only when I use 'AI Platform Deep Learning Containers'
I want to serve R model using App Engine. I am following this example R with app engine, but stuck. everything works when I do not use 'AI Platform Deep Learning Containers' ,details below.
Please refer to my code app.yaml
service: caret-custom
runtime: custom
env: flex
readiness_check:
app_start_timeout_sec: 1800
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
Dockerfile
FROM gcr.io/deeplearning-platform-release/r-cpu
#FROM gcr.io/gcer-public/plumber-appengine <-- code works using this container
RUN R -e "install.packages(c('caret', 'xgboost', 'rjson', 'plumber','googleCloudStorageR','googleAuthR'), repos='http://cran.rstudio.com/')"
WORKDIR /payload/
COPY [".", "./"]
EXPOSE 8080
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8080,swagger=TRUE)"]
CMD ["main.R"]
main.R
print("in rest controller program")
#* @get /demoR
get_predict_length <- function(){
dataset <- iris
# create the model
model <- lm(Petal.Length ~ Petal.Width, data = dataset)
petal_width = "0.4"
#petal_width = '0.4'
# convert the input to a number
petal_width <- as.numeric(petal_width)
#create the prediction data frame
prediction_data <- data.frame(Petal.Width=petal_width)
# create the prediction
predict(model,prediction_data)
}
I deploy using 'gcloud app deploy and its fails with below error ERROR: (gcloud.app.deploy) Error Response: [4] Your deployment has failed to become healthy in the allotted time and therefore was rolled back. If you believe this was an error, try adjusting the 'app_start_timeout_sec' setting in the 'readiness_check' section.
I increased 'app_start_timeout_sec' gradually from 300 to 1800 and now I get below error:
Updating service [caret1-custom] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Operation [apps/my-project-id/operations/7db0da8f-213b-476f-a6ba-9c8102b21cd5] timed out. This operation may still be underway.
Issue: If I use 'FROM gcr.io/gcer-public/plumber-appengine' in place of google provide container 'gcr.io/deeplearning-platform-release/r-cpu', everything is successful.
Please advice, as I am plan to use google provided containers only.
Ashishsr123