使用 Graviton GPU DLAMI TensorFlow - 深度学习 AMI
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Graviton GPU DLAMI TensorFlow

Amazon Deep Learning AMI 它已准备好与基于 Arm 处理器的 Graviton GPU 配合使用,并且已针对此进行了优化。 TensorFlowGraviton GPU DL TensorFlow AMI 包括一个 Python 环境,该环境预先配置了用于深度学习推理TensorFlow 用例的服务。有关Graviton GPU D TensorFlow LAMI的更多详细信息,请查看发行说明

验证 TensorFlow 服务可用性

运行以下命令以验证 Serving 的可用性和 TensorFlow 版本:

tensorflow_model_server --version

您的输出应类似于以下内容:

TensorFlow ModelServer: 0.0.0+dev.sha.3e05381e TensorFlow Library: 2.8.0

验证 TensorFlow 和提供 TensorFlow API 可用性

运行以下命令来验证 TensorFlow 和 TensorFlow 服务 API 的可用性:

python3 -c "import tensorflow, tensorflow_serving"

如果命令成功,则无任何输出。

使用服务运行示例推理 TensorFlow

使用以下命令下载预训练的 ResNet 50 模型并使用 TensorFlow Serving 运行推理:

# Clone the TensorFlow Serving repository git clone https://github.com/tensorflow/serving # Download pre-trained ResNet50 model mkdir -p ${HOME}/resnet/1 && cd ${HOME}/resnet/1 wget https://tfhub.dev/tensorflow/resnet_50/classification/1?tf-hub-format=compressed -O resnet_50_classification_1.tar.gz tar -xzvf resnet_50_classification_1.tar.gz && rm resnet_50_classification_1.tar.gz # Start TensorFlow Serving cd $HOME tensorflow_model_server \ --rest_api_port=8501 \ --model_name="resnet" \ --model_base_path="${HOME}/resnet" &

您的输出应类似于以下内容:

2021-11-10 06:18:51.028341: I tensorflow_serving/model_servers/server_core.cc:486] Finished adding/updating models 2021-11-10 06:18:51.028420: I tensorflow_serving/model_servers/server.cc:133] Using InsecureServerCredentials 2021-11-10 06:18:51.028460: I tensorflow_serving/model_servers/server.cc:383] Profiler service is enabled 2021-11-10 06:18:51.028889: I tensorflow_serving/model_servers/server.cc:409] Running gRPC ModelServer at 0.0.0.0:8500 ... [evhttp_server.cc : 245] NET_LOG: Entering the event loop ... 2021-11-10 06:18:51.030985: I tensorflow_serving/model_servers/server.cc:430] Exporting HTTP/REST API at:localhost:8501 ...

使用 Ser TensorFlow vin resnet_client g 示例来运行推理:

python3 serving/tensorflow_serving/example/resnet_client.py

您的输出应类似于以下内容:

2021-11-10 06:18:59.335327: I external/org_tensorflow/tensorflow/stream_executor/cuda/cuda_dnn.cc:368] Loaded cuDNN version 8204 2021-11-10 06:18:59.956156: I external/org_tensorflow/tensorflow/core/platform/default/subprocess.cc:304] Start cannot spawn child process Prediction class: 285, avg latency: 111.4673 ms

使用以下命令停止 TensorFlow 服务:

kill $(pidof tensorflow_model_server)
后续步骤

使用 Graviton GPU DLAMI PyTorch