{"id":15942210,"url":"https://github.com/discretetom/onnx-on-aws-lambda-arm64","last_synced_at":"2025-04-03T21:17:07.811Z","repository":{"id":250115258,"uuid":"833511220","full_name":"DiscreteTom/onnx-on-aws-lambda-arm64","owner":"DiscreteTom","description":"A demo to show how to run ONNX Runtime on AWS Lambda for arm64 runtimes.","archived":false,"fork":false,"pushed_at":"2024-08-22T01:23:42.000Z","size":20047,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T09:13:49.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DiscreteTom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-25T07:50:45.000Z","updated_at":"2025-01-28T20:47:37.000Z","dependencies_parsed_at":"2024-10-29T14:22:51.434Z","dependency_job_id":null,"html_url":"https://github.com/DiscreteTom/onnx-on-aws-lambda-arm64","commit_stats":null,"previous_names":["discretetom/onnx-on-aws-lambda-arm64"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fonnx-on-aws-lambda-arm64","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fonnx-on-aws-lambda-arm64/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fonnx-on-aws-lambda-arm64/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fonnx-on-aws-lambda-arm64/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiscreteTom","download_url":"https://codeload.github.com/DiscreteTom/onnx-on-aws-lambda-arm64/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247078867,"owners_count":20879953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T07:40:38.391Z","updated_at":"2025-04-03T21:17:07.789Z","avatar_url":"https://github.com/DiscreteTom.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ONNX on AWS Lambda ARM64\n\nThis is a demo to show how to run [ONNX Runtime](https://onnxruntime.ai/docs/get-started/with-python.html) on AWS Lambda for arm64 runtimes.\n\n## How This Works\n\nONNX Runtime works fine on x86 lambda, but on arm64 lambda you will get the following error:\n\n```\nError in cpuinfo: failed to parse the list of possible processors in /sys/devices/system/cpu/possible\nError in cpuinfo: failed to parse the list of present processors in /sys/devices/system/cpu/present\nError in cpuinfo: failed to parse both lists of possible and present processors\nterminate called after throwing an instance of 'onnxruntime::OnnxRuntimeException'\n```\n\nThat's because AWS Lambda remove these files for the simplicity of runtimes.\n\nIn Zip mode, you can't modify files in `/sys`, but in Container mode you can. This demo will copy [`patch.txt`](./hello_world/patch.txt) to `/sys/devices/system/cpu/possible` and `/sys/devices/system/cpu/present` to fix the issue. See the [Dockerfile](./hello_world/Dockerfile) for more details.\n\n\u003e [!IMPORTANT]\n\u003e You should modify the content of [`patch.txt`](./hello_world/patch.txt) corresponding to your Lambda function's memory configuration. The content should be `0-X` where `X` is the cpu count of the Lambda function ***minus 1***. You can use `os.cpu_count()` in python to checkout how many vCPUs are allocated for your memory configuration. E.g. when the memory is 128MB there will be 2 vCPUs and the content should be `0-1`; when the memory is 10240MB there will be 6 vCPUs and the content should be `0-5`.\n\n\u003e Why can't you generate `/sys/devices/system/cpu/possible` and `/sys/devices/system/cpu/present` during the runtime to write the correct vCPU count? That's because in Lambda only `/tmp` is writable. Thus you have to finish the patch process before the Lambda is invoked.\n\nThis demo uses [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) as the development framework.\n\n## Build\n\nDocker is required.\n\n```bash\nsam build -u\n```\n\n## Deploy\n\n```bash\nsam deploy -g\n```\n\n## Remote Test\n\n```bash\nsam remote invoke HelloWorldFunction --region us-east-1\n```\n\nYou can also test your function in the AWS management console.\n\n## Clean\n\n```bash\nsam delete --stack-name python-onnx\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fonnx-on-aws-lambda-arm64","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscretetom%2Fonnx-on-aws-lambda-arm64","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fonnx-on-aws-lambda-arm64/lists"}