是否可以在Google Cloud AI平台中同时使用GPU加速器和Torch进行模型部署?

时间:2020-03-09 10:14:30

标签: pytorch gcloud google-cloud-ml

我已经有一个火炬模型(BERT),并且我想使用ai平台服务来使用GPU进行在线预测,但是我不知道该怎么做。

以下没有加速器的命令有效:

gcloud alpha ai-platform versions create {VERSION} --model {MODEL_NAME} --origin=gs://{BUCKET}/models/ --python-version=3.5 --runtime-version=1.14 --package-uris=gs://{BUCKET}/packages/my-torch-package-0.1.tar.gz,gs://cloud-ai-pytorch/torch-1.0.0-cp35-cp35m-linux_x86_64.whl --machine-type=mls1-c4-m4 --prediction-class=predictor.CustomModelPrediction

但是,如果我尝试添加加速器参数:

--accelerator=^:^count=1:type=nvidia-tesla-k80

我收到以下错误消息:

ERROR: (gcloud.alpha.ai-platform.versions.create) INVALID_ARGUMENT: Field: version.machine_type Error: GPU accelerators are not supported on the requested machine type: mls1-c4-m4
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: 'GPU accelerators are not supported on the requested machine type:
      mls1-c4-m4'
    field: version.machine_type

但是,如果我使用其他机器类型,并且知道可以与加速器一起使用,则会出现以下错误:

ERROR: (gcloud.alpha.ai-platform.versions.create) FAILED_PRECONDITION: Field: framework Error: Machine type n1-highcpu-4 does not support CUSTOM_CLASS.
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: Machine type n1-highcpu-4 does not support CUSTOM_CLASS.
    field: framework

这就像任何支持GPU加速器的计算机都不支持自定义类(使用FATCH时必须使用AFAIK),而任何支持自定义类的计算机都不支持GPU加速器。

有什么方法可以使其正常工作吗?

有很多关于如何在Torch中使用ai平台的教程,但是我看不到使用gcloud来训练和预测是否必须在CPU上做所有事情的意义,这让我感到很奇怪

2 个答案:

答案 0 :(得分:1)

就目前而言,使用Custom Prediction Routines是Beta版。此外,在Beta中,使用other machine types而非mls1-c1-m2。

尽管如此,正如您在前面引用的link中所看到的那样,GPU无法用于类似于mls1的计算机。同时,这是唯一允许TensorFlow以外的模型的机器类型。

总而言之,目前可能无法在Torch中部署预测模型并使用GPU。

答案 1 :(得分:0)

Pytorch + GPU在AI平台预测中不可用,但是您仍然可以Deep Learning VM images并使用GPU创建自定义的Pytorch服务