Registry / ai-ml / mmgp
library3.7.6pypypiunverified

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.

pip install mmgp
INSTALL
IMPORT
SIG · MMGP
M
mmgp
ai-mlpythonv3.7.6
Install
76.7s avg
Import
Disk
4890MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.7.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 79.7s
py 3.11
✕ build_error
✓ 80.3s
py 3.12
✕ build_error
✓ 73.05s
py 3.13
✕ build_error
✓ 73.55s
py 3.9
✕ build_error
✕ build_error
4890MB installed
● package 4890MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

alloc
from mmgp import alloc
from mmgp import alloc
enum
from mmgp import enum
profile_type
from mmgp import profile_type

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.

import mmgp # Allocate 1MB of GPU memory sz = 1024 * 1024 # 1MB ptr = mmgp.alloc(sz) print(f"Allocated {sz} bytes at GPU pointer: {hex(ptr)}") # Allocate 512KB of zero-initialized GPU memory ptr_zeros = mmgp.zeros(512 * 1024) print(f"Allocated 512KB zero-initialized at GPU pointer: {hex(ptr_zeros)}") # Free the allocated memory mmgp.free(ptr) print(f"Freed {sz} bytes from GPU pointer: {hex(ptr)}") mmgp.free(ptr_zeros) print(f"Freed 512KB from GPU pointer: {hex(ptr_zeros)}")
Debug
Known issues
breakingmmgp is tightly coupled with tinygrad's internal memory management and helper utilities. Significant updates or breaking changes in tinygrad (especially its memory model) may necessitate corresponding updates or code changes in mmgp.
fix
Always check compatibility with the specific tinygrad version you are using. Refer to tinygrad's release notes and mmgp's `setup.py` or dependencies for compatible versions.
affects: All versions
gotchammgp provides low-level, manual GPU memory management. Users are fully responsible for correctly allocating and deallocating memory. Failure to `free` allocated pointers will lead to GPU memory leaks, and attempting to `free` an invalid or already freed pointer can lead to crashes or undefined behavior.
fix
Implement robust memory management practices. Use context managers if possible (though `mmgp` doesn't provide them directly for `alloc/free`), or ensure every `alloc` has a corresponding `free` exactly once. Debug memory issues carefully.
affects: All versions
gotchaDue to its direct interaction with GPU drivers and hardware, mmgp can be sensitive to specific GPU models, driver versions, and operating system configurations. This may lead to unexpected behavior or errors on certain setups.
fix
Test your application thoroughly across target hardware and driver versions. Consult the tinygrad community or issues for known compatibility problems with specific GPUs/drivers.
affects: All versions
Upgrade
Version history
3.7.6latest on PyPI · released Feb 20, 2026
Audit
Dependencies
tinygradrequiredCore functionality relies on `tinygrad.helpers` for low-level GPU interaction and often integrates with `tinygrad`'s memory model.
Agent activity
2 hits · last 30 days
node
2
Resources
mmgp — pip install mmgp · libregistry