This is the code I run
import ctypes
import time
import numpy as np
import torch.multiprocessing as mp

def subproc2(gpu, array):
    with array.get_lock():
        np_array = np.ctypeslib.as_array(array.get_obj())
        print(np_array[1000])
        if gpu == 0:
            np_array[999] = 0
        elif gpu == 1:
            np_array[1000] = 1 

    # keep process showing in "top"
    begin = time.time()
    while time.time() - begin < 10:
        a = 1 * 100

    return 0

if __name__ == "__main__":
    mp.set_start_method('spawn')
    array = mp.Array(ctypes.c_byte, 1000*1024*1024, lock=True)
    with array.get_lock():
        np_array = np.ctypeslib.as_array(array.get_obj())
        np_array.fill(100)

    print("allocated")
    mp.spawn(subproc2, args=(array,), nprocs=2)

    # keep process showing in "top"
    print(np_array[999:10001])
    begin = time.time()
    while time.time() - begin < 100:
        a = 1 * 100
    
    print('done')

The observations are :

Memory is only ever allocated in the main process.
If I don’t set the start method to spawn on Linux, I get a SIGSEGV even on access in subproc2.

Now what I want to test next is if I pass this memory on to dataloaders as is - an np.array, if it will increase memory consumption.
Let me do that now.