Open Zhangyanbo opened 5 years ago
I run the pyphi.compute.phi(subsystem)
about 2000 times and the program slowed down.
Hello,
Can you give more details? The information in your issue is not sufficient to address the problem.
Please provide your:
Also, just to be clear: are you sure you mean CPU leakage and not memory leakage? I've never heard of CPU leakage.
I will provide more information soon. And yes, I mean CPU leakage not memory leakage.
Thanks. In that case, could you please also clarify what you mean by that term?
It seems the PyPhi is using multiple threads to do computation. But when you finished a Phi computing, some threads may not stoped and still using CPU.
You can try this program and you will see the time cost is growing. While I'm always doing the same computing:
from sympy.combinatorics.graycode import GrayCode
from itertools import permutations
import numpy as np
import warnings
import pyphi
import pandas as pd
import time
ntimes = 10
each_time_compute = 20
warnings.filterwarnings('ignore')
labels = ('A', 'B', 'C')
m = [[0, 0, 0],
[0, 0, 1],
[1, 0, 1],
[1, 0, 0],
[1, 1, 0],
[1, 1, 1],
[1, 1, 1],
[1, 1, 0]]
def is_in(state, tpm):
for astate in tpm:
if state == astate.tolist():
return True
return False
def getphi(tpm):
network = pyphi.Network(tpm, node_labels=labels)
phis = []
for i in range(2):
for j in range(2):
for k in range(2):
state = (i, j, k)
node_indices = (0, 1, 2)
if is_in(list(state), tpm):
subsystem = pyphi.Subsystem(network, state, node_indices)
phis += [pyphi.compute.phi(subsystem)]
return phis
# Show CPU Leakage
for i in range(ntimes):
start = time.time()
for j in range(each_time_compute):
temp = getphi(np.array(m))
end = time.time()
print('epco', i, 'time cost:', end-start, 's')
Thank you. It appears that this is related to parallel cut evaluation. Can you please confirm that there is no increase in computation time when you set pyphi.config.PARALLEL_CUT_EVALUATION = False
?
Yes! The time cost does not grow after setting pyphi.config.PARALLEL_CUT_EVALUATION = False
. Do you know why it happens?
When repeatly run
pyphi.compute.phi(subsystem)
, the CPU using is continue growing and the program speed is contiune slowing down.