I tried running below codes as .py file on our own Linux server and it worked OK
Thanks!
maybe the problem is with .ipynb
import torch
import numpy as np
import torch.multiprocessing as mp
from torch.multiprocessing import set_start_method

def train1():
    print("\nx")
    q5 = np.random.randint(2,size=(4,2))
    q5_targ = torch.tensor(q5).to(torch.device("cuda"))

def train2():
    print("\ny")
    g5 = np.random.randint(2,size=(4,2))
    g5_targ = torch.tensor(g5).to(torch.device("cuda"))

if __name__ == '__main__':
    set_start_method('spawn')
    p1 = mp.Process(target=train1, args=())
    p2 = mp.Process(target=train2, args=())

    p1.start()
    p2.start()

    p1.join()
    p2.join()