hi
I am trying to train a model using multiprocessing.
In the example below (Multiprocessing best practices — PyTorch 1.6.0 documentation 32), model.share_memory() is used.
import torch.multiprocessing as mp
from model import MyModel

def train(model):
    # Construct data_loader, optimizer, etc.
    for data, labels in data_loader:
        optimizer.zero_grad()
        loss_fn(model(data), labels).backward()
        optimizer.step()  # This will update the shared parameters

if __name__ == '__main__':
    num_processes = 4
    model = MyModel()
    # NOTE: this is required for the ``fork`` method to work
    model.share_memory()
    processes = []
    for rank in range(num_processes):
        p = mp.Process(target=train, args=(model,))
        p.start()
        processes.append(p)
    for p in processes:
        p.join()

What exactly does shared memory mean??
Is a model created for each process??
Or is it that each process uses one model shared??
I don’t really understand what is in the document (IPC through shared memory - GeeksforGeeks 15).
thank you.