Bonjour,
je souhaite lancer un programme avec plusieurs processeurs. D'un part sur mon laptop (qui a 4 coeurs) puis sur un ordinateur d'un cluster (qui a 64 coeurs). Pour cela, apres avoir regarder sur internet, j'utilise la bibliotheque multiprocessing car le threading semble deconseille sous python
Lorsque je le lance sur mon pc, mon code tourne bien et je vois que cela tourne correctement sur les 4 processeurs.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from multiprocessing import Process,Queue threads = [] q = Queue() nbrThread=4 for thread in range(0,nbrThread): print("Launching thread...."+str(thread)) t=Process(target=function_test, args=(currentMat,q)) t.start() threads.append(t) print("Waiting for treads....") for thread in range(0,nbrThread): threads[thread].join() while not q.empty(): temp=q.get() coeff_output[temp[0]]=temp[1]
Alors que lorsque je le lance sur le cluster, il a bien l'air de passer dans les threads mais sans les lancer, et il ne print pas "Waiting for threads". Pourtant les 64 processeurs ont bien l'air de "tourner" (lorsque je lance la connabd "top" sous linux, chaque processeur est occupé )
Voila l'output que j'ai:
Launhcing thread....0
Launhcing thread....1
Launhcing thread....2
Launhcing thread....3
Launhcing thread....4
Launhcing thread....5
Launhcing thread....6
Launhcing thread....7
Launhcing thread....8
Launhcing thread....9
Launhcing thread....10
Launhcing thread....11
Launhcing thread....12
Launhcing thread....13
Launhcing thread....14
Launhcing thread....15
Launhcing thread....16
Launhcing thread....17
Launhcing thread....18
Launhcing thread....19
Launhcing thread....20
Launhcing thread....21
Launhcing thread....22
Launhcing thread....23
Launhcing thread....24
Launhcing thread....25
Launhcing thread....26
Launhcing thread....27
Launhcing thread....28
Launhcing thread....29
Launhcing thread....30
Launhcing thread....31
Launhcing thread....32
Launhcing thread....33
Launhcing thread....34
Launhcing thread....35
Launhcing thread....36
Launhcing thread....37
Launhcing thread....38
Launhcing thread....39
Launhcing thread....40
Launhcing thread....41
Launhcing thread....42
Launhcing thread....43
Launhcing thread....44
Launhcing thread....45
Launhcing thread....46
Launhcing thread....47
Launhcing thread....48
Launhcing thread....49
Launhcing thread....50
Launhcing thread....51
Launhcing thread....52
Launhcing thread....53
Launhcing thread....54
Launhcing thread....55
Launhcing thread....56
Launhcing thread....57
Launhcing thread....58
Launhcing thread....59
Launhcing thread....60
Launhcing thread....61
Launhcing thread....62
Launhcing thread....63
Partager