Skip to main content

Tag: python

Python Numpy Array Shared Between Processes

Python’s multiprocessing.shared_memory module provides a way to share a block of memory between processes. It’s usefull in ml contexts, where an app will runs ML model in separate process and wants share the results with its parent process. Frigate NVR does exacly that, see: object_detection.py. # Define properties of shared memory SHARED_MEMORY_NAME = "shm-1" SHARED_MEMORY_SHAPE = (5, 5) NP_DATA_TYPE = np.float64 # Calculate shared numpy array size dsize = np.dtype(NP_DATA_TYPE).itemsize * np.