{"id":15469119,"url":"https://github.com/epwalsh/rust-dl-webserver","last_synced_at":"2025-04-30T21:42:18.207Z","repository":{"id":40421719,"uuid":"250095528","full_name":"epwalsh/rust-dl-webserver","owner":"epwalsh","description":"🦀 Example of serving deep learning models in Rust with batched prediction","archived":false,"fork":false,"pushed_at":"2023-03-09T18:57:16.000Z","size":859,"stargazers_count":34,"open_issues_count":6,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T20:11:19.280Z","etag":null,"topics":["deep-learning","gpt2","libtorch","text-generation"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/epwalsh.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":"2020-03-25T21:29:16.000Z","updated_at":"2024-10-16T01:55:40.000Z","dependencies_parsed_at":"2024-10-23T07:30:26.004Z","dependency_job_id":null,"html_url":"https://github.com/epwalsh/rust-dl-webserver","commit_stats":{"total_commits":62,"total_committers":3,"mean_commits":"20.666666666666668","dds":0.4838709677419355,"last_synced_commit":"0464ab757cdd385ffd05a30c66f303325828c734"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epwalsh%2Frust-dl-webserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epwalsh%2Frust-dl-webserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epwalsh%2Frust-dl-webserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epwalsh%2Frust-dl-webserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epwalsh","download_url":"https://codeload.github.com/epwalsh/rust-dl-webserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251788891,"owners_count":21644075,"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":["deep-learning","gpt2","libtorch","text-generation"],"created_at":"2024-10-02T01:51:18.351Z","updated_at":"2025-04-30T21:42:18.152Z","avatar_url":"https://github.com/epwalsh.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-dl-webserver\n\nThis project provides an example of serving a deep learning model with batched prediction using Rust.\nIn particular it runs a GPT2 model from [rust-bert](https://github.com/guillaume-be/rust-bert) to generate text based on input context.\n\n## Features\n\n- Batched prediction using [`batched-fn`](https://github.com/epwalsh/batched-fn) when GPU is detected.\n- Back pressure mechanism that will return a 503 status code if the server gets back-logged with too many requests.\n\n## Running the server\n\nIn order for the server to make use of your GPU (if you have one available) you'll need to compile it against the right\nversion of the LibTorch C++ library, which you can download from\n[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/).\n\nAfter downloading, unzip the file and then run the server with\n\n```bash\nmake run LIBTORCH=/path/to/libtorch\n```\n\nIf you don't have a GPU available, just run\n\n```bash\nmake run\n```\n\nNow in a separate terminal you can send several requests in to the server at once:\n\n```bash\ncurl -d '{\"text\":\"Hello, World!\"}' \\\n    -H \"Content-Type: application/json\" \\\n    http://localhost:3030/generate \u0026\ncurl -d '{\"text\":\"Stay at home\"}' \\\n    -H \"Content-Type: application/json\" \\\n    http://localhost:3030/generate \u0026\ncurl -d '{\"text\":\"Wash your hands\"}' \\\n    -H \"Content-Type: application/json\" \\\n    http://localhost:3030/generate \u0026\ncurl -d '{\"text\":\"Do not touch your face\"}' \\\n    -H \"Content-Type: application/json\" \\\n    http://localhost:3030/generate \u0026\n```\n\nThe logs from the server should look something like this:\n\n![server output](img/server_output.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepwalsh%2Frust-dl-webserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepwalsh%2Frust-dl-webserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepwalsh%2Frust-dl-webserver/lists"}