File size: 819 Bytes
672b9f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import torch
import time
from multiprocessing import Pool, set_start_method


def run_on_single_gpu(device):
    a = torch.randn(1000,1000).cuda(device)
    b = torch.randn(1000,1000).cuda(device)
    ta = a
    tb = b
    while True:
        a = ta
        b = tb
        a = torch.sin(a)
        b = torch.sin(b)
        a = torch.cos(a)
        b = torch.cos(b)
        a = torch.tan(a)
        b = torch.tan(b)
        a = torch.exp(a)
        b = torch.exp(b)
        a = torch.log(a)
        b = torch.log(b)
        b = torch.matmul(a, b)
        #time.sleep(0.000005)

if __name__ == '__main__':
    set_start_method('spawn')
    print('start running')
    num_gpus = torch.cuda.device_count()
    pool = Pool(processes=num_gpus)
    pool.map(run_on_single_gpu, range(num_gpus))
    pool.close()
    pool.join()