Configuring an NVIDIA Jetson TX2
Configuring an NVIDIA Jetson TX2
To run this tutorial on an NVIDIA Jetson TX2, you provide source images and configure the Lambda function. To use the GPU for inference, you must install CUDA 9.0 and cuDNN 7.0 on your device when you image your board with Jetpack 3.3. You must also add local device resources.
To learn how to configure your Jetson so you can install the AWS IoT Greengrass Core software, see Setting Up Other Devices.
-
Download static PNG or JPG images for the Lambda function to use for image classification. The example works best with small image files.
Save your image files in the directory that contains the
inference.py
file (or in a subdirectory of this directory). This is in the Lambda function deployment package that you upload in Step 3: Create an Inference Lambda Function.Note
You can instead choose to instrument a camera on the Jetson board to capture the source images. However, we strongly recommend you start with static images first.
-
Edit the configuration of the Lambda function. Follow the procedure in Step 4: Add the Lambda Function to the Greengrass Group.
-
Increase the Memory limit value. To use the provided model in GPU mode, use 2048 MB.
-
Increase the Timeout value to 5 minutes. This ensures that the request does not time out too early. It takes a few minutes after setup to run inference.
-
For Lambda lifecycle, choose Make this function long-lived and keep it running indefinitely.
-
For Read access to /sys directory, choose Enable.
-
-
Add the required local device resources.
-
On the group configuration page, choose Resources.
-
On the Local tab, choose Add a local resource.
-
Define each resource:
-
For Resource name and Device path, use the values in the following table. Create one device resource for each row in the table.
-
For Resource type, choose Device.
-
For Group owner file access permission, choose Automatically add OS group permissions of the Linux group that owns the resource.
-
For Lambda function affiliations, grant Read and write access to your Lambda function.
Name
Device path
nvhost-ctrl
/dev/nvhost-ctrl
nvhost-gpu
/dev/nvhost-gpu
nvhost-ctrl-gpu
/dev/nvhost-ctrl-gpu
nvhost-dbg-gpu
/dev/nvhost-dbg-gpu
nvhost-prof-gpu
/dev/nvhost-prof-gpu
nvmap
/dev/nvmap
-
-
Troubleshooting AWS IoT Greengrass ML Inference
If the test is not successful, you can try the following troubleshooting steps. Run the commands in your Raspberry Pi terminal.
Check error logs
-
Switch to the root user and navigate to the
log
directory. Access to AWS IoT Greengrass logs requires root permissions.sudo su cd /greengrass/ggc/var/log
-
Check
runtime.log
for any errors.cat system/runtime.log | grep 'ERROR'
You can also look in your user-defined Lambda function log for any errors:
cat user/
your-region
/your-account-id
/lambda-function-name
.log | grep 'ERROR'For more information, see Troubleshooting with Logs.
Verify the Lambda function is successfully deployed
-
List the contents of the deployed Lambda in the
/lambda
directory. Replace the placeholder values before you run the command.cd /greengrass/ggc/deployment/lambda/arn:aws:lambda:
region
:account
:function:function-name
:function-version
ls -la -
Verify that the directory contains the same content as the
optimizedImageClassification.zip
deployment package that you uploaded in Step 3: Create an Inference Lambda Function.Make sure that the
.py
files and dependencies are in the root of the directory.
Verify the inference model is successfully deployed
-
Find the process identification number (PID) of the Lambda runtime process:
ps aux | grep
lambda-function-name
In the output, the PID appears in the second column of the line for the Lambda runtime process.
-
Enter the Lambda runtime namespace. Be sure to replace the placeholder
pid
value before you run the command.Note
This directory and its contents are in the Lambda runtime namespace, so they aren't visible in a regular Linux namespace.
sudo nsenter -t
pid
-m /bin/bash -
List the contents of the local directory that you specified for the ML resource.
Note
If your ML resource path is something other than
ml_model
, you must substitute that here.cd /ml_model ls -ls
You should see the following files:
56 -rw-r--r-- 1 ggc_user ggc_group 56703 Oct 29 20:07 model.json 196152 -rw-r--r-- 1 ggc_user ggc_group 200855043 Oct 29 20:08 model.params 256 -rw-r--r-- 1 ggc_user ggc_group 261848 Oct 29 20:07 model.so 32 -rw-r--r-- 1 ggc_user ggc_group 30564 Oct 29 20:08 synset.txt
Lambda function cannot find /dev/dri/renderD128
This can occur if OpenCL cannot connect to the GPU devices it needs. You must create device resources for the necessary devices for your Lambda function.
Next Steps
Next, explore other optimized models. For information, see the Amazon SageMaker Neo documentation.