{"id":17632740,"url":"https://github.com/jatinx/pyhip","last_synced_at":"2025-09-21T00:52:49.933Z","repository":{"id":40577600,"uuid":"423099970","full_name":"jatinx/PyHIP","owner":"jatinx","description":"Python Interface to HIP and hiprtc Library","archived":false,"fork":false,"pushed_at":"2025-05-12T22:38:58.000Z","size":68,"stargazers_count":9,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-06T06:12:58.766Z","etag":null,"topics":["bindings","cuda","gpu","hip","hiprtc","python","rocm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jatinx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-10-31T09:06:51.000Z","updated_at":"2025-08-22T09:16:05.000Z","dependencies_parsed_at":"2022-08-27T02:15:31.808Z","dependency_job_id":"26ac87f3-7645-47b9-b251-1f0f4f24a863","html_url":"https://github.com/jatinx/PyHIP","commit_stats":{"total_commits":37,"total_committers":9,"mean_commits":4.111111111111111,"dds":0.5945945945945945,"last_synced_commit":"58e055851fc14afc714318300b77a17e92b9180f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jatinx/PyHIP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jatinx%2FPyHIP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jatinx%2FPyHIP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jatinx%2FPyHIP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jatinx%2FPyHIP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jatinx","download_url":"https://codeload.github.com/jatinx/PyHIP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jatinx%2FPyHIP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276179894,"owners_count":25598571,"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","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bindings","cuda","gpu","hip","hiprtc","python","rocm"],"created_at":"2024-10-23T01:45:27.698Z","updated_at":"2025-09-21T00:52:49.880Z","avatar_url":"https://github.com/jatinx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyHIP - Python Interface of [HIP](https://github.com/ROCm-Developer-Tools/HIP) and [hip-on-nv](https://github.com/jatinx/hip-on-nv)\n\n## Introduction\n\nThis small python lib which hooks into HIP library and provides pythonic interface to it.\n\nThere are two parts of it, hip library and hiprtc library.\n\nThis also works with [hip-on-nv](https://github.com/jatinx/hip-on-nv).\n\n## Installation\n\n### Prerequisites\n\nBefore installing pyhip-interface, please make sure you have the following prerequisites installed:\n\n* The Heterogeneous Interface for Portability - [HIP Installation Guide](https://docs.amd.com/bundle/HIP-Installation-Guide-v5.3/page/Introduction_to_HIP_Installation_Guide.html)\n\n### Install with pip\n\nPyHIP can be installed using pip, a package manager for Python. Run the following command in your terminal to install:\n\n`pip install pyhip-interface`\n\n### Install from source\n\nAlternatively, you can install PyHIP from the source code. First, clone the repository from GitHub:\n\n`git clone https://github.com/jatinx/PyHIP`\n\nThen, navigate to the repository directory and run the following command to install:\n\n`python setup.py install`\n\n## Example Usage\n\n```python\nimport ctypes\nfrom pyhip import hip, hiprtc\nsource = \"\"\"\nextern \"C\" __global__ void set(int *a) {\n  *a = 10;\n}\n\"\"\"\nprog = hiprtc.hiprtcCreateProgram(source, 'set', [], [])\ndevice_properties = hip.hipGetDeviceProperties(0)\nprint(f\"Compiling kernel for {device_properties.gcnArchName}\")\nif hip.hipGetPlatformName() == 'amd': # offload arch is amd only\n  hiprtc.hiprtcCompileProgram(prog, [f'--offload-arch={device_properties.gcnArchName}'])\nelse:\n  hiprtc.hiprtcCompileProgram(prog, [])\ncode = hiprtc.hiprtcGetCode(prog)\nmodule = hip.hipModuleLoadData(code)\nkernel = hip.hipModuleGetFunction(module, 'set')\nptr = hip.hipMalloc(4)\n\nclass PackageStruct(ctypes.Structure):\n  _fields_ = [(\"a\", ctypes.c_void_p)]\n\nstruct = PackageStruct(ptr)\nhip.hipModuleLaunchKernel(kernel, 1, 1, 1, 1, 1, 1, 0, 0, struct)\nres = ctypes.c_int(0)\nhip.hipMemcpy_dtoh(ctypes.byref(res), ptr, 4)\nprint(res.value)\n```\n\n## Testing\n\nTesting is in it's infancy. I'll try to add more as and when I get some time. Any help here is appreciated :)\n\n### How to run tests\n\nMake sure you have ```pytest``` package installed.\n\nFrom the project folder run ```pytest ./tests/* -v -r A```\n\n## Help needed\n\nIf you are an opensource developer and want to contribute to this project, I can use your help in several places depending on your skillset.\n\n- Adding more tests to the project\n- Adding API documentation and samples\n- Improving HIP API coverage - adding meaningful APIs instead of direct mapping.\n\n## Common Problems\n\n- Unable to load hip or hiprtc library - OSError: libamdhip64.so: cannot open shared object file: No such file or directory.\n\n  - Make sure that LD_LIBRARY_PATH has hip path on it (/opt/rocm/lib or a custom installation path)\n\n- Getting error and need to debug\n\n  - Set AMD_LOG_LEVEL=7 for maximum verbosity of HIP APIs (this only works on amd platform).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjatinx%2Fpyhip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjatinx%2Fpyhip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjatinx%2Fpyhip/lists"}