Many thanks @bapi
I added mp.set_start_method('spawn', force=True) into the code below. Would this be right?
import numpy as np
import torch
import torch.multiprocessing as mp
from torch.multiprocessing import Pool

X = np.array([[1, 3, 2, 3], [2, 3, 5, 6], [1, 2, 3, 4]])
X = torch.DoubleTensor(X).cuda()

def X_power_func(j):
    X_power = X**j
    return X_power

if __name__ == '__main__':
  mp.set_start_method('spawn', force=True)
  with Pool(processes = 1) as p:   # Paralleizing over 2 GPUs
    results = p.map(X_power_func, range(2))

results

Also, how do I specify the device ids for multiple GPUs for my code?
Sorry if I have too many questions.