ML 影像分類連接器 - AWS IoT Greengrass

AWS IoT Greengrass Version 1 於 2023 年 6 月 30 日進入延長使用壽命階段。如需詳細資訊,請參閱AWS IoT Greengrass V1 維護政策。在此日期之後, AWS IoT Greengrass V1 將不會發行提供功能、增強功能、錯誤修正或安全性修補程式的更新。在上運行的設備 AWS IoT Greengrass V1 不會中斷,並將繼續運行並連接到雲。我們強烈建議您移轉至 AWS IoT Greengrass Version 2,這會增加重要的新功能,並支援其他平台

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ML 影像分類連接器

警告

此連接器已進入延長使用壽命階段,AWS IoT Greengrass不會發行提供功能、現有功能增強功能、安全性修補程式或錯誤修正的更新。如需詳細資訊,請參閱AWS IoT Greengrass Version 1維護政策

ML 映像分類連接器提供在AWS IoT Greengrass核心上執行的機器學習 (ML) 推論服務。這項本機推論服務會使用影像分類演算法訓練的模型來執行 SageMaker 影像分類。

使用者定義的 Lambda 函數使用 M AWS IoT Greengrass achine Learning SDK,將推論請求提交至本機推論服務。此服務在本機執行推論,並傳回輸入映像屬於特定類別的機率。

AWS IoT Greengrass 提供此連接器的下列版本,可用於多種平台。

Version 2

連接器

描述和 ARN

毫升圖像分類系統 64 日元 X2

適用於 NVIDIA Jetson TX2 的映像分類推論服務。支援 GPU 加速。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationAarch64JTX2/versions/2

毫升圖像分類

適用於 x86_64 平台的映像分類推論服務。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationx86-64/versions/2

毫升圖像分類

適用於 ARMv7 平台的影像分類推論服務。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationARMv7/versions/2

Version 1

連接器

描述和 ARN

毫升圖像分類系統 64 日元 X2

適用於 NVIDIA Jetson TX2 的映像分類推論服務。支援 GPU 加速。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationAarch64JTX2/versions/1

毫升圖像分類

適用於 x86_64 平台的映像分類推論服務。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationx86-64/versions/1

毫升圖像分類

適用於 Armv7 平台的映像分類推論服務。

ARNarn:aws:greengrass:region::/connectors/ImageClassificationARMv7/versions/1

如需版本變更的詳細資訊,請參閱 Changelog

需求

這些連接器有下列要求:

Version 2
  • AWS IoT Greengrass核心軟體 v1.9.3 或更新版本。

  • Python 版本 3.7 或 3.8 安裝在核心設備上,並添加到 PATH 環境變量。

    注意

    要使用 Python 3.8,請運行以下命令,從默認 Python 3.7 安裝文件夾創建一個符號鏈接到已安裝的 Python 3.8 二進製文件。

    sudo ln -s path-to-python-3.8/python3.8 /usr/bin/python3.7

    這會設定您的裝置以符合 AWS IoT Greengrass 的 Python 需求。

  • 對安裝在核心裝置上的 Apache MXNet 架構的相依性。如需詳細資訊,請參閱在 AWS IoT Greengrass 核心安裝 MXNet 相依性

  • 參考模型來源之 Greengrass 群組中的 ML 資源。 SageMaker 此模型必須經過 SageMaker 影像分類演算法進行訓練。如需詳細資訊,請參閱 Amazon SageMaker 開發人員指南中的映像分類演算法

  • ML 回饋連接器已新增至 Greengrass 群組並進行設定。只有在您想要使用連接器上傳模型輸入資料,並將預測發佈至 MQTT 主題時,才需要此項目。

  • Greengrass 群組角色設定為允許對目標訓練工作sagemaker:DescribeTrainingJob執行動作,如下列範例 IAM 政策所示。

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sagemaker:DescribeTrainingJob" ], "Resource": "arn:aws:sagemaker:region:account-id:training-job:training-job-name" } ] }

    針對群組角色要求,您必須設定角色以授與必要的許可,並確認已將角色新增至群組。如需詳細資訊,請參閱管理 Greengrass 群組角色 (主控台)管理 Greengrass 群組角色 (CLI)

    您可以為資源授予細微或條件式存取 (例如,使用萬用字元 * 命名配置)。如果您日後變更目標訓練工 future,請務必更新群組角色。

  • AWS IoT Greengrass需要 M@@ achine Learning SDK v1.1.0 才能與此連接器互動。

Version 1
  • AWS IoT Greengrass核心軟件 v1.7 或更高版本。

  • Python 版本 2.7 安裝在核心設備上,並添加到 PATH 環境變量中。

  • 對安裝在核心裝置上的 Apache MXNet 架構的相依性。如需詳細資訊,請參閱在 AWS IoT Greengrass 核心安裝 MXNet 相依性

  • 參考模型來源之 Greengrass 群組中的 ML 資源。 SageMaker 此模型必須經過 SageMaker 影像分類演算法進行訓練。如需詳細資訊,請參閱 Amazon SageMaker 開發人員指南中的映像分類演算法

  • Greengrass 群組角色設定為允許對目標訓練工作sagemaker:DescribeTrainingJob執行動作,如下列範例 IAM 政策所示。

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sagemaker:DescribeTrainingJob" ], "Resource": "arn:aws:sagemaker:region:account-id:training-job:training-job-name" } ] }

    針對群組角色要求,您必須設定角色以授與必要的許可,並確認已將角色新增至群組。如需詳細資訊,請參閱管理 Greengrass 群組角色 (主控台)管理 Greengrass 群組角色 (CLI)

    您可以為資源授予細微或條件式存取 (例如,使用萬用字元 * 命名配置)。如果您日後變更目標訓練工 future,請務必更新群組角色。

  • AWS IoT Greengrass需要 M@@ achine Learning SDK v1.0.0 或更新版本才能與此連接器互動。

連接器參數

這些連接器提供下列參數。

Version 2
MLModelDestinationPath

Lambda 環境中 ML 資源的絕對本機路徑。這是指定給機器學習資源的目的地路徑。

注意

如果是在主控台建立機器學習資源,則這是本機路徑。

AWS IoT主控台中的顯示名稱:模型目標路徑

需要:true

類型:string

有效模式:.+

MLModelResourceId

參考來源模型的機器學習資源 ID。

AWS IoT主控台中的顯示名稱:SageMaker 工作 ARN 資源

需要:true

類型:string

有效模式:[a-zA-Z0-9:_-]+

MLModelSageMakerJobArn

代表 SageMaker 模型來源之 SageMaker 訓練工作的 ARN。模型必須經過 SageMaker 影像分類演算法進行訓練。

AWS IoT主控台中的顯示名稱:SageMaker 工作 ARN

需要:true

類型:string

有效模式:^arn:aws:sagemaker:[a-zA-Z0-9-]+:[0-9]+:training-job/[a-zA-Z0-9][a-zA-Z0-9-]+$

LocalInferenceServiceName

本機推論服務的名稱。使用者定義的 Lambda 函數會將名稱傳遞給 Machine L AWS IoT Greengrass earning SDK 的invoke_inference_service函數來叫用服務。如需範例,請參閱 用法示例

AWS IoT主控台中的顯示名稱:本機推論服務名稱

需要:true

類型:string

有效模式:[a-zA-Z0-9][a-zA-Z0-9-]{1,62}

LocalInferenceServiceTimeoutSeconds

推論請求終止之前的時間 (以秒為單位)。最小值為 1。

AWS IoT控制台中的顯示名稱:超時(秒)

需要:true

類型:string

有效模式:[1-9][0-9]*

LocalInferenceServiceMemoryLimitKB

服務可存取的記憶體數量 (KB)。最小值為 1。

AWS IoT主控台中的顯示名稱:記憶體限制 (KB)

需要:true

類型:string

有效模式:[1-9][0-9]*

GPUAcceleration

CPU 或 GPU (加速) 運算環境。此內容僅適用於 ML 映像分類 Aarch64 JTX2 連接器。

AWS IoT控制台中的顯示名稱:GPU 加速

需要:true

類型:string

有效值:CPUGPU

MLFeedbackConnectorConfigId

用來上傳模型輸入資料的意見回饋組態 ID。這必須符合針對 ML 意見回饋連接器定義的意見回饋組態 ID。

只有在您想要使用 ML 意見回饋連接器上傳模型輸入資料,並將預測發佈至 MQTT 主題時,才需要此參數。

AWS IoT主控台中的顯示名稱:ML 回饋連接器組態識別碼

需要:false

類型:string

有效模式:^$|^[a-zA-Z0-9][a-zA-Z0-9-]{1,62}$

Version 1
MLModelDestinationPath

Lambda 環境中 ML 資源的絕對本機路徑。這是指定給機器學習資源的目的地路徑。

注意

如果是在主控台建立機器學習資源,則這是本機路徑。

AWS IoT主控台中的顯示名稱:模型目標路徑

需要:true

類型:string

有效模式:.+

MLModelResourceId

參考來源模型的機器學習資源 ID。

AWS IoT主控台中的顯示名稱:SageMaker 工作 ARN 資源

需要:true

類型:string

有效模式:[a-zA-Z0-9:_-]+

MLModelSageMakerJobArn

代表 SageMaker 模型來源之 SageMaker 訓練工作的 ARN。模型必須經過 SageMaker 影像分類演算法進行訓練。

AWS IoT主控台中的顯示名稱:SageMaker 工作 ARN

需要:true

類型:string

有效模式:^arn:aws:sagemaker:[a-zA-Z0-9-]+:[0-9]+:training-job/[a-zA-Z0-9][a-zA-Z0-9-]+$

LocalInferenceServiceName

本機推論服務的名稱。使用者定義的 Lambda 函數會將名稱傳遞給 Machine L AWS IoT Greengrass earning SDK 的invoke_inference_service函數來叫用服務。如需範例,請參閱 用法示例

AWS IoT主控台中的顯示名稱:本機推論服務名稱

需要:true

類型:string

有效模式:[a-zA-Z0-9][a-zA-Z0-9-]{1,62}

LocalInferenceServiceTimeoutSeconds

推論請求終止之前的時間 (以秒為單位)。最小值為 1。

AWS IoT控制台中的顯示名稱:超時(秒)

需要:true

類型:string

有效模式:[1-9][0-9]*

LocalInferenceServiceMemoryLimitKB

服務可存取的記憶體數量 (KB)。最小值為 1。

AWS IoT主控台中的顯示名稱:記憶體限制 (KB)

需要:true

類型:string

有效模式:[1-9][0-9]*

GPUAcceleration

CPU 或 GPU (加速) 運算環境。此內容僅適用於 ML 映像分類 Aarch64 JTX2 連接器。

AWS IoT控制台中的顯示名稱:GPU 加速

需要:true

類型:string

有效值:CPUGPU

建立範例連接器 (AWS CLI)

下列 CLI 命令會建立ConnectorDefinition包含 ML 映像分類連接器的初始版本。

範例:CPU 執行個體

此範例會建立 ML 映像分類 ArmV7l 連接器的執行個體。

aws greengrass create-connector-definition --name MyGreengrassConnectors --initial-version '{ "Connectors": [ { "Id": "MyImageClassificationConnector", "ConnectorArn": "arn:aws:greengrass:region::/connectors/ImageClassificationARMv7/versions/2", "Parameters": { "MLModelDestinationPath": "/path-to-model", "MLModelResourceId": "my-ml-resource", "MLModelSageMakerJobArn": "arn:aws:sagemaker:us-west-2:123456789012:training-job:MyImageClassifier", "LocalInferenceServiceName": "imageClassification", "LocalInferenceServiceTimeoutSeconds": "10", "LocalInferenceServiceMemoryLimitKB": "500000", "MLFeedbackConnectorConfigId": "MyConfig0" } } ] }'
範例:GPU 執行個體

此範例會建立 ML 影像分類 Aarch64 JTX2 連接器的執行個體,該連接器支援 NVIDIA 傑特森 TX2 主機板上的 GPU 加速。

aws greengrass create-connector-definition --name MyGreengrassConnectors --initial-version '{ "Connectors": [ { "Id": "MyImageClassificationConnector", "ConnectorArn": "arn:aws:greengrass:region::/connectors/ImageClassificationAarch64JTX2/versions/2", "Parameters": { "MLModelDestinationPath": "/path-to-model", "MLModelResourceId": "my-ml-resource", "MLModelSageMakerJobArn": "arn:aws:sagemaker:us-west-2:123456789012:training-job:MyImageClassifier", "LocalInferenceServiceName": "imageClassification", "LocalInferenceServiceTimeoutSeconds": "10", "LocalInferenceServiceMemoryLimitKB": "500000", "GPUAcceleration": "GPU", "MLFeedbackConnectorConfigId": "MyConfig0" } } ] }'
注意

這些連接器中的 Lambda 函數具有長壽命的生命週期。

在AWS IoT Greengrass主控台中,您可以從群組的 [連接器] 頁面新增連接器。如需詳細資訊,請參閱Greengrass 連接器入門 (主控台)

輸入資料

這些連接器接受影像檔做為輸入。輸入影像檔必須採用 jpegpng 格式。如需詳細資訊,請參閱用法示例

這些連接器不接受 MQTT 郵件作為輸入資料。

輸出資料

這些連接器會傳回輸入影像中所識別物件的格式化預測:

[0.3,0.1,0.04,...]

預測包含一個清單,列出模型訓練期間與訓練資料集所使用之類別對應的值。每個值代表影像落在對應類別下的機率。具有最高機率的類別是主導預測。

這些連接器不會將 MQTT 訊息發佈為輸出資料。

用法示例

下列範例 Lambda 函數使用 M AWS IoT Greengrassachine Learning SDK 與 ML 影像分類連接器互動。

範例初始化軟體開發套件用戶端,並同步呼叫軟體開發套件的 invoke_inference_service 函數,以叫用本機推論服務。它會傳入演算法類型、服務名稱、映像類型和映像內容。然後,範例會剖析服務回應以獲得機率結果 (預測)。

Python 3.7
import logging from threading import Timer import numpy as np import greengrass_machine_learning_sdk as ml # We assume the inference input image is provided as a local file # to this inference client Lambda function. with open('/test_img/test.jpg', 'rb') as f: content = bytearray(f.read()) client = ml.client('inference') def infer(): logging.info('invoking Greengrass ML Inference service') try: resp = client.invoke_inference_service( AlgoType='image-classification', ServiceName='imageClassification', ContentType='image/jpeg', Body=content ) except ml.GreengrassInferenceException as e: logging.info('inference exception {}("{}")'.format(e.__class__.__name__, e)) return except ml.GreengrassDependencyException as e: logging.info('dependency exception {}("{}")'.format(e.__class__.__name__, e)) return logging.info('resp: {}'.format(resp)) predictions = resp['Body'].read().decode("utf-8") logging.info('predictions: {}'.format(predictions)) # The connector output is in the format: [0.3,0.1,0.04,...] # Remove the '[' and ']' at the beginning and end. predictions = predictions[1:-1] count = len(predictions.split(',')) predictions_arr = np.fromstring(predictions, count=count, sep=',') # Perform business logic that relies on the predictions_arr, which is an array # of probabilities. # Schedule the infer() function to run again in one second. Timer(1, infer).start() return infer() def function_handler(event, context): return
Python 2.7
import logging from threading import Timer import numpy import greengrass_machine_learning_sdk as gg_ml # The inference input image. with open("/test_img/test.jpg", "rb") as f: content = f.read() client = gg_ml.client("inference") def infer(): logging.info("Invoking Greengrass ML Inference service") try: resp = client.invoke_inference_service( AlgoType="image-classification", ServiceName="imageClassification", ContentType="image/jpeg", Body=content, ) except gg_ml.GreengrassInferenceException as e: logging.info('Inference exception %s("%s")', e.__class__.__name__, e) return except gg_ml.GreengrassDependencyException as e: logging.info('Dependency exception %s("%s")', e.__class__.__name__, e) return logging.info("Response: %s", resp) predictions = resp["Body"].read() logging.info("Predictions: %s", predictions) # The connector output is in the format: [0.3,0.1,0.04,...] # Remove the '[' and ']' at the beginning and end. predictions = predictions[1:-1] predictions_arr = numpy.fromstring(predictions, sep=",") logging.info("Split into %s predictions.", len(predictions_arr)) # Perform business logic that relies on predictions_arr, which is an array # of probabilities. # Schedule the infer() function to run again in one second. Timer(1, infer).start() infer() # In this example, the required AWS Lambda handler is never called. def function_handler(event, context): return

Machine L AWS IoT Greengrass earning SDK 中的invoke_inference_service函數接受下列引數。

引數

描述

AlgoType

用於推論之演算法類型的名稱。目前僅支援 image-classification

需要:true

類型:string

有效值:image-classification

ServiceName

本機推論服務的名稱。使用您設定連接器時為 LocalInferenceServiceName 參數指定的名稱。

需要:true

類型:string

ContentType

輸入映像的 mime 類型。

需要:true

類型:string

有效值:image/jpeg, image/png

Body

輸入映像檔的內容。

需要:true

類型:binary

在 AWS IoT Greengrass 核心安裝 MXNet 相依性

若要使用 ML 映像分類連接器,您必須在核心裝置上安裝 Apache MXNet 架構的相依性。連接器使用架構來支援機器學習模型。

注意

這些連接器隨附預先編譯的 MXNet 程式庫,因此您不需要在核心裝置上安裝 MXNet 架構。

AWS IoT Greengrass 提供指令碼來安裝適用於下列常見平台和裝置的相依性 (或用於安裝參考)。如果您使用的是不同平台或裝置,請參閱 MXNet 文件做為組態的參考。

在安裝 MXNet 相依性之前,請確保所需的系統程式庫 (使用指定的最低版本) 存在於裝置上。

NVIDIA Jetson TX2
  1. 安裝 CUDA Toolkit 9.0 和 cuDNN 7.0。您可以按照入門教學課程的設定其他裝置中的指示。

  2. 啟用世界各地的儲存庫,讓連接器可以安裝社群維護的開放式軟體。如需詳細資訊,請參閱 Ubuntu 文件中的儲存庫/Ubuntu

    1. 開啟 /etc/apt/sources.list 檔案。

    2. 務必註銷以下幾行。

      deb http://ports.ubuntu.com/ubuntu-ports/ xenial universe deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial universe deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe
  3. 在核心裝置上將以下安裝指令碼的複本儲存成名為 nvidiajtx2.sh 的檔案。

    Python 3.7Python 2.7
    Python 3.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." echo 'Assuming that universe repos are enabled and checking dependencies...' apt-get -y update apt-get -y dist-upgrade apt-get install -y liblapack3 libopenblas-dev liblapack-dev libatlas-base-dev apt-get install -y python3.7 python3.7-dev python3.7 -m pip install --upgrade pip python3.7 -m pip install numpy==1.15.0 python3.7 -m pip install opencv-python || echo 'Error: Unable to install OpenCV with pip on this platform. Try building the latest OpenCV from source (https://github.com/opencv/opencv).' echo 'Dependency installation/upgrade complete.'
    注意

    如果 OpenCV 未使用此指令碼成功安裝,您可以嘗試從來源建置。如需詳細資訊,請參閱 OpenCV 文件中的 Installation in Linux,或參閱適用於您平台的其他線上資源。

    Python 2.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." echo 'Assuming that universe repos are enabled and checking dependencies...' apt-get -y update apt-get -y dist-upgrade apt-get install -y liblapack3 libopenblas-dev liblapack-dev libatlas-base-dev python-dev echo 'Install latest pip...' wget https://bootstrap.pypa.io/get-pip.py python get-pip.py rm get-pip.py pip install numpy==1.15.0 scipy echo 'Dependency installation/upgrade complete.'
  4. 從您儲存檔案的目錄中,執行下列命令:

    sudo nvidiajtx2.sh
x86_64 (Ubuntu or Amazon Linux)
  1. 在核心裝置上將以下安裝指令碼的複本儲存成名為 x86_64.sh 的檔案。

    Python 3.7Python 2.7
    Python 3.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." release=$(awk -F= '/^NAME/{print $2}' /etc/os-release) if [ "$release" == '"Ubuntu"' ]; then # Ubuntu. Supports EC2 and DeepLens. DeepLens has all the dependencies installed, so # this is mostly to prepare dependencies on Ubuntu EC2 instance. apt-get -y update apt-get -y dist-upgrade apt-get install -y libgfortran3 libsm6 libxext6 libxrender1 apt-get install -y python3.7 python3.7-dev elif [ "$release" == '"Amazon Linux"' ]; then # Amazon Linux. Expect python to be installed already yum -y update yum -y upgrade yum install -y compat-gcc-48-libgfortran libSM libXrender libXext else echo "OS Release not supported: $release" exit 1 fi python3.7 -m pip install --upgrade pip python3.7 -m pip install numpy==1.15.0 python3.7 -m pip install opencv-python || echo 'Error: Unable to install OpenCV with pip on this platform. Try building the latest OpenCV from source (https://github.com/opencv/opencv).' echo 'Dependency installation/upgrade complete.'
    注意

    如果 OpenCV 未使用此指令碼成功安裝,您可以嘗試從來源建置。如需詳細資訊,請參閱 OpenCV 文件中的 Installation in Linux,或參閱適用於您平台的其他線上資源。

    Python 2.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." release=$(awk -F= '/^NAME/{print $2}' /etc/os-release) if [ "$release" == '"Ubuntu"' ]; then # Ubuntu. Supports EC2 and DeepLens. DeepLens has all the dependencies installed, so # this is mostly to prepare dependencies on Ubuntu EC2 instance. apt-get -y update apt-get -y dist-upgrade apt-get install -y libgfortran3 libsm6 libxext6 libxrender1 python-dev python-pip elif [ "$release" == '"Amazon Linux"' ]; then # Amazon Linux. Expect python to be installed already yum -y update yum -y upgrade yum install -y compat-gcc-48-libgfortran libSM libXrender libXext python-pip else echo "OS Release not supported: $release" exit 1 fi pip install numpy==1.15.0 scipy opencv-python echo 'Dependency installation/upgrade complete.'
  2. 從您儲存檔案的目錄中,執行下列命令:

    sudo x86_64.sh
Armv7 (Raspberry Pi)
  1. 在核心裝置上將以下安裝指令碼的複本儲存成名為 armv7l.sh 的檔案。

    Python 3.7Python 2.7
    Python 3.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." apt-get update apt-get -y upgrade apt-get install -y liblapack3 libopenblas-dev liblapack-dev apt-get install -y python3.7 python3.7-dev python3.7 -m pip install --upgrade pip python3.7 -m pip install numpy==1.15.0 python3.7 -m pip install opencv-python || echo 'Error: Unable to install OpenCV with pip on this platform. Try building the latest OpenCV from source (https://github.com/opencv/opencv).' echo 'Dependency installation/upgrade complete.'
    注意

    如果 OpenCV 未使用此指令碼成功安裝,您可以嘗試從來源建置。如需詳細資訊,請參閱 OpenCV 文件中的 Installation in Linux,或參閱適用於您平台的其他線上資源。

    Python 2.7
    #!/bin/bash set -e echo "Installing dependencies on the system..." apt-get update apt-get -y upgrade apt-get install -y liblapack3 libopenblas-dev liblapack-dev python-dev # python-opencv depends on python-numpy. The latest version in the APT repository is python-numpy-1.8.2 # This script installs python-numpy first so that python-opencv can be installed, and then install the latest # numpy-1.15.x with pip apt-get install -y python-numpy python-opencv dpkg --remove --force-depends python-numpy echo 'Install latest pip...' wget https://bootstrap.pypa.io/get-pip.py python get-pip.py rm get-pip.py pip install --upgrade numpy==1.15.0 picamera scipy echo 'Dependency installation/upgrade complete.'
  2. 從您儲存檔案的目錄中,執行下列命令:

    sudo bash armv7l.sh
    注意

    在 Raspberry Pi 上,使用 pip 來安裝機器學習相依性是一種記憶體密集型操作,可能會導致裝置記憶體不足、無法回應。若要解決這項問題,您可以暫時增加交換大小:

    /etc/dphys-swapfile 中,增加 CONF_SWAPSIZE 變數的值,然後執行下列命令來重新啟動 dphys-swapfile

    /etc/init.d/dphys-swapfile restart

記錄與疑難排解

根據您的群組設定,事件和錯誤記錄會寫入 CloudWatch 記錄檔、本機檔案系統或兩者。來自這個連接器的日誌使用字首 LocalInferenceServiceName。如果連接器發生非預期的行為,請檢查連接器的日誌。日誌通常會包含有用的偵錯資訊,例如遺失機器學習程式庫相依性或連接器啟動失敗的原因。

如果AWS IoT Greengrass群組設定為寫入本機記錄,則連接器會將記錄檔寫入greengrass-root/ggc/var/log/user/region/aws/。如需 Greengrass 記錄的詳細資訊,請參閱。使用 AWS IoT Greengrass 日誌進行監控

使用下列資訊可協助疑難排解 ML 映像分類連接器的問題。

必要系統程式庫

下列索引標籤會列出每個 ML 影像分類連接器所需的系統程式庫。

ML Image Classification Aarch64 JTX2
程式庫 最低版本
ld-linux-aarch64.so.1GLIBC_2.17
libc.so.6GLIBC_2.17
libcublas.so.9.0不適用
libcudart.so.9.0不適用
libcudnn.so.7不適用
libcufft.so.9.0不適用
libcurand.so.9.0不適用
libcusolver.so.9.0不適用
libgcc_s.so.1GCC_4.2.0
libgomp.so.1GOMP_4.0, OMP_1.0
libm.so.6GLIBC_2.23
libpthread.so.0GLIBC_2.17
librt.so.1GLIBC_2.17
libstdc++.so.6GLIBCXX_3.4.21, CXXABI_1.3.8
ML Image Classification x86_64
程式庫 最低版本
ld-linux-x百分之六十二GCC_4.0.0
libc.so.6GLIBC_2.4
libgfortran.so.3GFORTRAN_1.0
libm.so.6GLIBC_2.23
libpthread.so.0GLIBC_2.2.5
librt.so.1GLIBC_2.2.5
libstdc++.so.6CXXABI_1.3.8, GLIBCXX_3.4.21
ML Image Classification Armv7
程式庫 最低版本
ld-linux-armhf. 所以GLIBC_2.4
libc.so.6GLIBC_2.7
libgcc_s.so.1GCC_4.0.0
libgfortran.so.3GFORTRAN_1.0
libm.so.6GLIBC_2.4
libpthread.so.0GLIBC_2.4
librt.so.1GLIBC_2.4
libstdc++.so.6CXXABI_1.3.8、CXXABI_ARM_1.3.3、GLIBCXX_3.4.20

問題

徵狀 解決方案

在 Raspberry Pi 上,下列錯誤訊息已記錄,並且您不是使用相機:Failed to initialize libdc1394

執行下列命令以停用驅動程式:

sudo ln /dev/null /dev/raw1394

此操作為暫時性,符號連結在重新啟動就會消失。請參閱您作業系統版本的手冊,了解如何在重新啟動時自動建立連結。

许可证

ML 映像分類連接器包含下列協力廠商軟體/授權:

Intel OpenMP Runtime Library 授權。英特尔® OpenMP* 運行時間是雙重許可的,具有商業(COM)許可證作為英特爾® 并行工作室 XE 套件產品的一部分,以及 BSD 開放源代碼(OSS)許可證。

此連接器是根據 Greengrass 核心軟體授權合約發行的。

Changelog

下表說明每個版本連接器的變更。

版本

變更

2

已新增MLFeedbackConnectorConfigId參數以支援使用 ML 回饋連接器上傳模型輸入資料、將預測發佈到 MQTT 主題,以及將指標發佈到 Amazon。 CloudWatch

1

初始版本。

Greengrass 群組一次只能包含一個版本的連接器。若要取得有關升級連接器版本的資訊,請參閱升級連接器版本

另請參閱