By using AWS re:Post, you agree to the Terms of Use

Deploy an model trained using Sagemaker's built-in k-NN algorithm for AWS Panorama


Hi, I'm trying to use a k-Nearest Neighbour model for deployment to an Edge device (AWS Panorama). I understand I need to create an optimized model to suit the target device. As I understand it the built-in algorithms all include a SageMaker Neo 'compile_model' function which I am running over my trained model -

Build model..

knn = sagemaker.estimator.Estimator(container,
# Setup the hyperparameters
knn.set_hyperparameters(**hyperparams), job_name=job_name)

Build optimised model...

optimized_ic = knn.compile_model(
    input_shape={"data": [1,3,512,512]},

While the initial model builds fine I get an error running the optimised model / compile_model function:

Failed. Reason: ClientError: InputConfiguration: No valid Mxnet model file -symbol.json found. Please make sure the framework you select is correct.

I can find a few google references for attempts at something similar with KMeans algorithm, but is k-NN algorithm dramatically different? Do I just have the wrong settings? I understand all of the built-in algorithms use were originally mxnet trained? When I extract my model I only have three files:

  • model_algo-1
  • model_algo-1.json
  • model_algo-1-labels.npy

I am struggling to work out where I am going wrong in porting this model!

  • I have similarly tried the SageMaker Neo conversion using the 'Panorama Test Utility' and the steps suggested to optimise the model there. The problem again seems to be an issue with the knn trained model not being based on mxnet or missing a '-symbol.json' file?

1 Answer

The default Panorama service leverages NEO to compile and run the models. Unfortunately, the 1P Sagemaker algorithms are not compatible with NEO. Also, the Panorama service leverages Nvidia Jetson hardware, which is not compatible with the 'ml.m5.2xlarge' hardware. With that said, Panorama now supports an option to "bring your own runtime" to Panorama that has recently been introduced that would allow you to leverage 1P Sagemaker models. If you were to train your model with a GPU enabled instance (p3 or g4dn), the process would involve building your own custom container for Panorama with the MXNET 1.4 version installed. If this is still something you are pursuing, reach out and I can help walk you through the process.

answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions