Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The PyPhi package may have CPU leaking #28

Open
Zhangyanbo opened this issue Mar 14, 2019 · 9 comments
Open

The PyPhi package may have CPU leaking #28

Zhangyanbo opened this issue Mar 14, 2019 · 9 comments

Comments

@Zhangyanbo
Copy link

When repeatly run pyphi.compute.phi(subsystem), the CPU using is continue growing and the program speed is contiune slowing down.

@Zhangyanbo
Copy link
Author

I run the pyphi.compute.phi(subsystem) about 2000 times and the program slowed down.

@wmayner
Copy link
Owner

wmayner commented Mar 14, 2019

Hello,

Can you give more details? The information in your issue is not sufficient to address the problem.

Please provide your:

  1. Python version
  2. Operating system and version
  3. PyPhi version
  4. A minimal working example

Also, just to be clear: are you sure you mean CPU leakage and not memory leakage? I've never heard of CPU leakage.

@Zhangyanbo
Copy link
Author

I will provide more information soon. And yes, I mean CPU leakage not memory leakage.

@wmayner
Copy link
Owner

wmayner commented Mar 14, 2019

Thanks. In that case, could you please also clarify what you mean by that term?

@Zhangyanbo
Copy link
Author

Zhangyanbo commented Mar 14, 2019

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.

@Zhangyanbo
Copy link
Author

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')

@Zhangyanbo
Copy link
Author

  1. Python version: 3.7
  2. Operating system and version: Ubuntu 18.04.2 LTS
  3. PyPhi version: 1.1.0

@wmayner
Copy link
Owner

wmayner commented Mar 15, 2019

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?

@Zhangyanbo
Copy link
Author

Yes! The time cost does not grow after setting pyphi.config.PARALLEL_CUT_EVALUATION = False. Do you know why it happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants