# InternalServerException when running a model loaded on S3

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%3E%5C
**Category:** Amazon SageMaker\
**Created:** [August 5, 2021, 4:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003 "2021-08-05T16:16:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicente-m47](https://avatars.discourse-cdn.com/v4/letter/v/d78d45/32.png) [@vicente-m47](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvicente-m47)%5C
**Post date:** [August 5, 2021, 4:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%2F1 "2021-08-05T16:16:36Z")

</div>

Hi there,

I am trying to deploy a model loaded on S3, following the steps found mainly on this video: `[Deploy a Hugging Face Transformers Model from S3 to Amazon SageMaker](https://www.youtube.com/watch?v=pfBGgSGnYLs)`.

For that I have downloaded a model into a S3 bucket and use this image URI for DLC: image\_uri = “[763104351884.dkr.ecr.eu-west-1.amazonaws.com/huggingface-pytorch-inference:1.7.1-transformers4.6.1-cpu-py36-ubuntu18.04](http://763104351884.dkr.ecr.eu-west-1.amazonaws.com/huggingface-pytorch-inference:1.7.1-transformers4.6.1-cpu-py36-ubuntu18.04)”

When I run the `predictor.predict(data)` command, I get this error:

 ![Captura de pantalla 2021-08-05 a las 18.13.38](https://us1.discourse-cdn.com/hellohellohello/original/2X/1/19c170c28efde9c5736302eb4dbe82ad90648e49.png)

The model I use fot these tests is this one: dccuchile/bert-base-spanish-wwm-uncased, and I could not find the way for letting the model know which action should perform.

I am pretty new with HuggingFace technology, and probably I am missing the point for fixing that.

Please, could you let me know what should I do for informing the model about what to do?

Thank you!

---

<div class="post-metadata">

**Author:** ![philschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philschmid/32/38022_2.png) [@philschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fphilschmid)%5C
**Post date:** [August 5, 2021, 4:32pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%2F2 "2021-08-05T16:32:47Z")

</div>

Hey @vicente-m47 ,

Could you please provide the whole code you executed?

If you want to deploy a model from [Models - Hugging Face](http://hf.co/models) you can use the “deploy” button on each of the model pages.

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/f/f3bc1380f200efb1f3b8537bae51b79d17aab288.png)  
This will generate a code snippet for you  
 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/9/934cc3edf7c6064c9eb3a8977f80d93e7a61671a.png)

From reading the code you attached you are trying to send an input for `question-answering` to a model (dccuchile/bert-base-spanish-wwm-uncased), which is not fine-tuned for `question-answering`, also you are sending an English input to a Spanish model.

A good starting point for new Hugging Facer is our course at [Introduction - Hugging Face Course](http://hf.co/course).  
You can find more information about deploying to sagemaker in the documentation here [Deploy models to Amazon SageMaker](https://huggingface.co/docs/sagemaker/inference)

---

<div class="post-metadata">

**Author:** ![vicente-m47](https://avatars.discourse-cdn.com/v4/letter/v/d78d45/32.png) [@vicente-m47](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvicente-m47)%5C
**Post date:** [August 6, 2021, 7:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%2F3 "2021-08-06T07:04:42Z")

</div>

Hi, @philschmid,

Sorry, you are right, my question was awfully written. Here is the code I used:

`!pip install sagemaker --upgrade`

```auto
from sagemaker.huggingface import HuggingFaceModel
import sagemaker

role = sagemaker.get_execution_role()

# This model was supposedly trained from the dccuchile Bert model for QA.
model = "s3://xxxxxxx/hg_model.tar.gz"
image_uri = "763104351884.dkr.ecr.eu-west-1.amazonaws.com/huggingface-pytorch-inference:1.7.1-transformers4.6.1-cpu-py36-ubuntu18.04"

huggingface_model = HuggingFaceModel(
    model_data=model,
    transformers_version='4.6.1',
    pytorch_version='1.7.1',
    py_version='py36',
    image_uri=image_uri,
    role=role, 
)

```

```auto
predictor = huggingface_model.deploy(
    initial_instance_count=1,
    instance_type="ml.m5.xlarge"
)

```

```auto
data = {
    "inputs": {
        "question": "¿Cómo me llamo?",
        "context": "Mi nombre es Juan y vivo en Francia"
    }
}

predictor.predict(data)

```

Reading your comment, I understand that the problem should be on the trained model. I would review the course you recommend and check the training I did.

Thank you!

---

<div class="post-metadata">

**Author:** ![philschmid](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philschmid/32/38022_2.png) [@philschmid](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fphilschmid)%5C
**Post date:** [August 6, 2021, 7:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%2F4 "2021-08-06T07:53:04Z")

</div>

You don’t need to provide an `image_uri` the HuggingFaceModel will select the right one based on `pytorch_version` and `transformers_version`.

---

<div class="post-metadata">

**Author:** ![vicente-m47](https://avatars.discourse-cdn.com/v4/letter/v/d78d45/32.png) [@vicente-m47](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvicente-m47)%5C
**Post date:** [August 6, 2021, 9:39am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Finternalserverexception-when-running-a-model-loaded-on-s3%2F9003%2F5 "2021-08-06T09:39:19Z")

</div>

Yes, you’re right. Thank you, @philschmid.
