在RStudio上部署带有cloudml的Keras模型失败

问题描述 投票:0回答:3

我正在尝试在Google Cloud ML上部署我训练过的keras模型。该模型在我的本地计算机上运行良好,但无法在云中部署。我正在使用macOS High Sierra(10.13.4)上的RStudio上的cloudml库。

这是一个玩具示例:

model <- keras_model_sequential()

model %>%
  layer_dense(units = 78, activation = "sigmoid", input_shape = c(39)) %>%
  layer_dense(units = 39, activation = "sigmoid") %>%
  layer_dense(units = 20, activation = "sigmoid") %>%
  layer_dense(units = 1, activation = "sigmoid") %>% 
  compile(
    loss = 'mean_squared_error',
    optimizer = optimizer_rmsprop(),
    metrics = c('mean_squared_error')
  )

history <- model %>% fit(
  x_train, y_train,
  epochs = 1000,
  validation_split = 0.2
)

# deploy
export_savedmodel(model, "model")
cloudml_deploy("model", name = "keras_model")

这是我的版本信息:

> R.Version()
$platform
[1] "x86_64-apple-darwin15.6.0"

$arch
[1] "x86_64"

$os
[1] "darwin15.6.0"

$system
[1] "x86_64, darwin15.6.0"   

$status
[1] ""

$major
[1] "3"

$minor
[1] "4.1"

$year
[1] "2017"

$month
[1] "06"

$day
[1] "30"

$`svn rev`
[1] "72865" 

$language
[1] "R"

$version.string
[1] "R version 3.4.1 (2017-06-30)"

$nickname
[1] "Single Candle"

我的RStudio版本是1.1.423。本地R库版本是:

cloudml: 0.5
keras: 2.1.6.9001
tensorflow: 1.5.0.9001

我得到的错误信息是

Creating version (this might take a few minutes)
..............................................
..............................................
..............................................
..............................................
..............................................
...........................failed.
ERROR: (gcloud.ml-engine.versions.create) Bad model 
detected with error:  "Failed to load model: Loading 
servable: {name: default version: 1} failed: Not found: 
Op type not registered 'ClipByValue' in binary running 
on localhost. Make sure the Op and Kernel are registered 
in the binary running in this process.\n\n (Error code: 0

什么是错的?

r tensorflow keras google-cloud-ml
3个回答
1
投票

cloudml R包中,要使用TensorFlow 1.8,您可以将cloudml.yml设置为:

trainingInput: runtimeVersion: 1.8

然后像往常一样部署cloudml_deploy("model", name = "keras_model")以使用TensorFlow 1.8运行时进行部署。


0
投票

听起来这个图是在较新版本的TensorFlow上生成的,其中包括ClipByValue op(1.8 +),但在旧版本上没有使用。最简单的解决方案是使用较新版本的TensorFlow进行部署,但可能您可以使用较旧的TensorFlow版本(1.8之前)生成图形。


0
投票

创建版本时,请指定标志--runtime-version=1.8

© www.soinside.com 2019 - 2024. All rights reserved.