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

konlpy multiprocessing 실험 #1

Closed
hexists opened this issue Apr 10, 2020 · 2 comments
Closed

konlpy multiprocessing 실험 #1

hexists opened this issue Apr 10, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@hexists
Copy link
Owner

hexists commented Apr 10, 2020

konlpy multiprocessing 실험

@hexists hexists added the enhancement New feature or request label Apr 10, 2020
@hexists hexists self-assigned this Apr 10, 2020
hexists pushed a commit that referenced this issue Apr 10, 2020
hexists pushed a commit that referenced this issue Apr 11, 2020
@hexists
Copy link
Owner Author

hexists commented Apr 11, 2020

실험 내용 정리

multi processing 으로 인한 오류인지 확인하고, 해결 방법을 찾아봅니다.

실험 과정

  • 같은 코드로 증상이 재현되는지 확인
  • 오류가 출력될 경우, 오류를 해결할 수 있는지 확인
  • 해결 방법을 정리 후 공유

실험 내용

  • 동일한 코드를 실행하는 경우, 몇가지 오류를 출력합니다.

  • 환경 변수 설정 오류

objc[47789]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[47789]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
objc[47790]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[47790]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
  • 환경 변수를 설정해서 해결했습니다. ref

    export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
    
  • 입력 데이터가 빈 경우(NaN)

Concurrent tagging:
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "./test_mt.py", line 17, in do_concurrent_tagging
    l = [k.pos(lines[i]) for i in range(start, end)]
  File "./test_mt.py", line 17, in <listcomp>
    l = [k.pos(lines[i]) for i in range(start, end)]
  File "/usr/local/lib/python3.7/site-packages/konlpy/tag/_kkma.py", line 55, in pos
    sentences = self.jki.morphAnalyzer(phrase)
TypeError: No matching overloads found for kr.lucypark.kkma.KkmaInterface.morphAnalyzer(float), options are:
	public java.util.List kr.lucypark.kkma.KkmaInterface.morphAnalyzer(java.lang.String) throws java.lang.Exception
  • NaN인 경우를 필터링 했습니다. ref

    filt_condition = dataset['document'].str.contains("", na=False)
    dataset = dataset[filt_condition]
    
  • 입력 데이터 분석에 오랜 시간이 걸리는 경우(OOM이 나거나 계속 실행됩니다.)

Traceback (most recent call last):
  File "./test_mp.py", line 69, in <module>
    results = pool.map(morphRow, dataset.iloc[:, 0].values)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
multiprocessing.pool.MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x114512b70>'. Reason: 'PicklingError("Can't pickle <java class 'java.lang.OutOfMemoryError'>: attribute lookup java.lang.OutOfMemoryError on konlpy.tag._kkma failed",)'
  • OOM 발생 원인을 찾기 위해, 데이터를 출력하면서 문제가 되는 값들을 정리했습니다.
    konlpy에서 발생한 문제이기 보다는 kkma에서 발생한 문제입니다.
    이미 이슈로 등록되어 있습니다. 해당되는 내용을 추가로 정리할 예정입니다.

실험 결과 및 결론

  • 오류를 확인해보니 kkma를 multiprocessing해서 나는 오류는 아니였습니다.
  • kkma에 있는 오류(분석이 오래걸리는, 안되는)로 인해 multiprocessing시에도 문제가 발생한 것으로,
    kkma의 오류를 수정하거나, kkma에서 문제가 될만한 입력을 제외하고 입력해야 합니다.
  • 위 내용들은 기존 이슈에 공유하고, 추가로 오류가 나는 입력들 또한 이슈에 댓글로 남기겠습니다.

@hexists
Copy link
Owner Author

hexists commented Apr 11, 2020

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

No branches or pull requests

1 participant