stardist / stardist

StarDist - Object Detection with Star-convex Shapes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stardist leads to kernel dies on MacOS Jupyter Notebook and aborted Python console

azhu513 opened this issue · comments

Describe the bug
Running StarDist2D.from_pretrained('2D_versatile_fluo') on my laptop caused kernel dies on Jupyter Notebook and aborted Python console

To reproduce

  from stardist.models import StarDist2D
  from csbdeep.utils import normalize
  from io import StringIO
  from filelock import FileLock

  assert dapi.ndim == 2

  with redirect_stdout(StringIO()): 
      with FileLock("stardist.lock"):
          _model = StarDist2D.from_pretrained('2D_versatile_fluo')
          
  labels, _=_model.predict_instances(normalize(dapi))

Error Message

In Jupyter Notebook

14:54:52.031 [error] Raw kernel process exited code: undefined
14:54:52.033 [error] Error in waiting for cell to complete Error: Canceled future for execute_request message before replies were done
    at t.KernelShellFutureHandler.dispose (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:2:32419)
    at ~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:2:51471
    at Map.forEach (<anonymous>)
    at v._clearKernelState (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:2:51456)
    at v.dispose (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:2:44938)
    at ~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:24:105531
    at te (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:2:1587099)
    at Zg.dispose (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:24:105507)
    at nv.dispose (~/.vscode/extensions/ms-toolsai.jupyter-2023.4.1011241018-darwin-x64/out/extension.node.js:24:112790)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
14:54:52.033 [warn] Cell completed with errors {
  message: 'Canceled future for execute_request message before replies were done'
}
14:54:52.034 [warn] Cancel all remaining cells due to cancellation or failure in execution

In Python console:

2023-05-22 14:38:34.379718: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
1/1 [==============================] - 1s 928ms/step
OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/
[1]    51296 abort      python

Environment:

  • StarDist 0.8.3
  • CSBDeep 0.7.3
  • TensorFlow 2.12.0
  • OS: MacOS Monterey 12.6.3
  • GPU memory (if applicable): N/A

Attempted solutions that didn't work for me

  1. Set 'KMP_DUPLICATE_LIB_OK' to 'True' by
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
  1. Install nomkl