{"library":"mmgp","title":"MMGP: GPU Memory Management","description":"mmgp (Memory Management for the GPU Poor) is a low-level Python library for direct GPU memory management, primarily designed for use with `tinygrad`. It provides functions for allocating and freeing raw memory on the GPU. As of version `3.7.6`, it offers granular control over GPU resources, allowing for efficient memory handling in performance-critical applications. Its release cadence is irregular, often aligning with `tinygrad` development.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install mmgp"],"cli":null},"imports":["from mmgp import alloc, free, zeros"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import mmgp\n\n# Allocate 1MB of GPU memory\nsz = 1024 * 1024 # 1MB\nptr = mmgp.alloc(sz)\nprint(f\"Allocated {sz} bytes at GPU pointer: {hex(ptr)}\")\n\n# Allocate 512KB of zero-initialized GPU memory\nptr_zeros = mmgp.zeros(512 * 1024)\nprint(f\"Allocated 512KB zero-initialized at GPU pointer: {hex(ptr_zeros)}\")\n\n# Free the allocated memory\nmmgp.free(ptr)\nprint(f\"Freed {sz} bytes from GPU pointer: {hex(ptr)}\")\n\nmmgp.free(ptr_zeros)\nprint(f\"Freed 512KB from GPU pointer: {hex(ptr_zeros)}\")","lang":"python","description":"This quickstart demonstrates basic GPU memory allocation and deallocation using `mmgp.alloc`, `mmgp.zeros`, and `mmgp.free`. It allocates memory, prints the returned pointer, and then frees it.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}