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 athttps://huggingface.co/docs/sagemaker/inference#deploy-a-model-from-the-hubI was able to successfully do this and the prediction works.I duplicated this notebook and change the model_id and task to‘HF_MODEL_ID’:‘hocheewai/videomae-base-finetuned-ucf101-subset’‘HF_TASK’:‘video-classification’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,https://huggingface.co/spaces/hocheewai/hocheewai-videomae-base-finetuned-ucf101-subset. 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”.Capture1436×622 78.7 KBIt 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. https://huggingface.co/models
hub = {
  'HF_MODEL_ID':'hocheewai/videomae-base-finetuned-ucf101-subset', # model_id from hf.co/models
  'HF_TASK':'video-classification' # NLP task you want to use for predictions
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
   env=hub,
   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
)
2023-08-10T15:39:09Z
The problem has been resolved. The solution is to extend the pre-built container763104351884.dkr.ecr.us-east-1.amazonaws.com/huggingface-pytorch-inference:2.0.0-transformers4.28.1-cpu-py310-ubuntu20.04by following the procedure atExtend a Pre-built Container - Amazon SageMakerThe “extension” is just to add RUN pip install decord.Also ensure the IAM role attached to your Sagemaker notebook has this permission,AmazonEC2ContainerRegistryFullAccessIf not, proceed to add it.Once I did these, I was able to predict successfully.