Skip to content

Timeout when importing torch #223

Open
@sudoprime

Description

@sudoprime

This example app.py always times out when import torch is included, but works without the import. The dockerfile works locally just fine. I have no explanation of the behavior. Whether I pip3 install torch or install from requirements.txt, the result is the same.

app.py

import json
import torch
import sys

def handler(event, context):
    return 'Hello from AWS Lambda using Python' + sys.version + '!'

Dockerfile

FROM public.ecr.aws/lambda/python:3.7

RUN pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu --target "${LAMBDA_TASK_ROOT}"

COPY app.py ${LAMBDA_TASK_ROOT}

CMD ["app.handler"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions