pytorch - 有没有办法在谷歌云 AI 平台中同时使用 GPU 加速器和 Torch 进行模型部署?
问题描述
我已经有一个 Torch 模型 (BERT),我想使用 ai-platform 服务来使用 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 加速器的机器不支持自定义类(需要 AFAIK 才能使用 Torch),并且任何支持自定义类的机器都不支持 GPU 加速器。
有什么办法让它工作吗?
有很多关于如何在 Torch 中使用 ai-platform 的教程,但是我看不出使用 gcloud 来训练和预测是否必须在 CPU 上做所有事情的意义,所以这对我来说感觉很奇怪。
解决方案
推荐阅读
- amazon-web-services - 当我尝试在 AWS Lambda 函数(python)中使用 bash 脚本创建文件时出现错误“只读文件系统”
- c++ - 使用 QProcess 调用带有参数的外部程序
- java - 使用 Android SDK 21 将新文件写入可移动存储中的其他应用程序数据目录时出错
- javascript - Axios 刷新令牌得到 401
- ns-3 - 在 NS3 中执行 Randomwalk2dmobility 时发生错误
- c++ - 为什么 mysql_init(nullptr) 会导致以下代码中的分段错误?
- upgrade - @author 在大量修改别人的代码时
- c# - UWP FolderPicker - 显示以父级为中心的对话框窗口
- graphql - 在单独的查询中加载 __typename 字段 Apollo-Client 未更新 UI
- xslt - 使用 XSLT,如何让文本插入仅出现在最后一段之后?