pyannote / pyannote-metrics

A toolkit for reproducible evaluation, diagnostic, and error analysis of speaker diarization systems
http://pyannote.github.io/pyannote-metrics
MIT License
184 stars 32 forks source link

RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. #8

Closed chananshgong closed 7 years ago

chananshgong commented 7 years ago

In init.py of metrics there is the following code:

from multiprocessing import Manager
manager_ = Manager()

which cause the following error when I try to run a diarization error measurement from command line using the famous if __name__=='__main__' :

File "c:\GongResearch\Speech\diarization\src\evaluation\der.py", line 1, in from pyannote.metrics.diarization import DiarizationErrorRate as PyAnnoteDiarizationErrorRate File "C:\Users\hanan.shteingart\Anaconda3\lib\site-packages\pyannote\metrics__init.py", line 40, in manager_ = Manager() File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\context.py", line 55, in Manager m.start() File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\managers.py", line 479, in start self._process.start() File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\context.py", line 313, in _Popen return Popen(process_obj) File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\popen_spawn_win32.py", line 34, in init__ prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\spawn.py", line 144, in get_preparation_data _check_not_importing_main() File "C:\Users\hanan.shteingart\Anaconda3\lib\multiprocessing\spawn.py", line 137, in _check_not_importing_main is not going to be frozen to produce an executable.''') RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

I have seen the comment in the code saying:

# Note: if you (yes, you!) know a better way to do this,
# please open a pull request.
# I had to use this global multiprocessing manager for it to be accessible
# from anywhere, and make parallel computation of evaluation metric a reality

But there is probably a workaround to run this from command line, is there?

chananshgong commented 7 years ago

Managed to go around it by moving the import statement of pyannote.metrics into the "main" body.