How to specify requirement for a decord Python library to SageMaker?

I did some exploration to deploy a videoMAE model on SageMaker. I managed to deploy but I was unable to confirm if I have done it correctly as I encountered some errors using it to do predictions.

For preliminaries, I replicated the steps verbatim at

I was able to successfully do this and the prediction works.

I duplicated this notebook and change the model_id and task to



This model (i.e., 'hocheewai/videomae-base-finetuned-ucf101-subset) is a just a duplicate of another model and has been deployed on Hugging Faces spaces, This model works in the Hugging Face Spaces environment.

Next, I attempted to deploy to SageMaker. I was also able to deploy to Sagemaker. However, when I attempt a prediction, I encounter an error,

““message”: “\nVideoClassificationPipeline requires the decord library but it was not found in your environment. You can install it with pip: pip install\ndecord. Please note that you may need to restart your runtime after installation.\n”.

It seems as if this Python library is missing from the environment that the SageMaker endpoint is pointing to.

Therefore, during deployment, how can I specify that there is a requirements for this library to SageMaker? Is it something to do with the following?

from sagemaker.huggingface import HuggingFaceModel

# Hub Model configuration.
hub = {
  'HF_MODEL_ID':'hocheewai/videomae-base-finetuned-ucf101-subset', # model_id from
  'HF_TASK':'video-classification' # NLP task you want to use for predictions

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
   role=role, # iam role with permissions to create an Endpoint
   transformers_version="4.26", # transformers version used
   pytorch_version="1.13", # pytorch version used
   py_version="py39", # python version of the DLC

The problem has been resolved. The solution is to extend the pre-built container

by following the procedure at Extend a Pre-built Container - Amazon SageMaker

The “extension” is just to add RUN pip install decord.

Also ensure the IAM role attached to your Sagemaker notebook has this permission,


If not, proceed to add it.

Once I did these, I was able to predict successfully.