{"id":18034512,"url":"https://github.com/sarthakpati/pytorchmodelimporttemplate","last_synced_at":"2026-05-02T04:38:09.074Z","repository":{"id":136644161,"uuid":"190064496","full_name":"sarthakpati/PyTorchModelImportTemplate","owner":"sarthakpati","description":"An example shoowing how to import a PyTorch model and use it using C++","archived":false,"fork":false,"pushed_at":"2019-06-10T15:56:52.000Z","size":1088,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T07:21:58.723Z","etag":null,"topics":["cmake","cpp","cpp11","medical-imaging","pytorch","pytorch-tutorial","torch","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/sarthakpati.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":"2019-06-03T18:58:25.000Z","updated_at":"2021-08-07T18:50:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f0727db-4573-4e36-859d-356da029d685","html_url":"https://github.com/sarthakpati/PyTorchModelImportTemplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarthakpati%2FPyTorchModelImportTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarthakpati%2FPyTorchModelImportTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarthakpati%2FPyTorchModelImportTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sarthakpati%2FPyTorchModelImportTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sarthakpati","download_url":"https://codeload.github.com/sarthakpati/PyTorchModelImportTemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261581,"owners_count":20910107,"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":["cmake","cpp","cpp11","medical-imaging","pytorch","pytorch-tutorial","torch","tutorial"],"created_at":"2024-10-30T11:12:17.440Z","updated_at":"2026-05-02T04:38:04.048Z","avatar_url":"https://github.com/sarthakpati.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTorchModelImportTemplate\nAn example showing how to import a PyTorch model and use it using C++\n\nAll code has been adopted from https://pytorch.org/tutorials/advanced/cpp_export.html\n\n## Depedencies\n\n* Download LibTorch binaries:\n  * https://pytorch.org/get-started/locally/\n  * Add the path to the **/share/cmake/Torch** folder from the extracted folder under the environment variable **CMAKE_PREFIX_PATH** (this will help CMake find Torch properly)\n    * [WINDOWS USERS] There is the option for Debug and Release libraries; you need to link to the appropriate one for your linker to work properly\n\n* Build from Source\n  * Python 3.6 from Anaconda - needed for PyTorch installation\n\n  * CMake 3.12 (3.13 and 3.14 have a configuration change with superbuild that makes things a bit messy) - needed for PyTorch installation\n\n  * PyTorch:\n\n    * Clone https://github.com/pytorch/pytorch; use a tag, preferably\n    * Update submodules\n    * Use CMake to configure and generate binaries.\n      * [WINDOWS USERS] use Visual Studio 2017 x64 as the generator from the GUI and add the variable **CMAKE_DEBUG_POSTFIX** as a **STRING** of value **d** (this makes linking against debug libs easier to maintain)\n    * Enable the following the flags **CAFFE2_STATIC_LINK_CUDA** and **TORCH_STATIC** and disable **BUILD_SHARED_LIBS** for static compiles \n    * An analogous command set in PowerShell or Bash is as follows:\n  \n```\ngit clone https://github.com/pytorch/pytorch.git # use a tag, preferably\ncd pytorch\ngit submodule update --init --recursive # updates all submodules \nmkdir bin; cd bin\ncmake -DCMAKE_INSTALL_PREFIX=./install .. # this will use the default generator for the system\n```\n\n  * Run the **INSTALL** target (either build that on VS or run `make install/strip` on bash)\n\n* ITK - for image I/O; can be replaced with something different, if needed\n\n  * Clone https://github.com/InsightSoftwareConsortium/ITK\n  * Checkout tag 4.13.2 - this is because the I/O dependencies have not yet been checked for 5.x\n  * Use CMake to configure and generate binaries \n  * An analogous command set in PowerShell or Bash is as follows:\n  \n```\ngit clone https://github.com/InsightSoftwareConsortium/ITK.git # use a tag, preferably\ngit checkout tags/v4.13.2\ncd ITK\nmkdir bin; cd bin\ncmake -DCMAKE_INSTALL_PREFIX=./install .. # this will use the default generator for the system\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarthakpati%2Fpytorchmodelimporttemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarthakpati%2Fpytorchmodelimporttemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarthakpati%2Fpytorchmodelimporttemplate/lists"}