tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

nightly tests: `deep_atlas/deep_atlas_tutorial.ipynb`

Open wyli opened this issue 3 years ago • 3 comments

Describe the bug

Running ./deep_atlas/deep_atlas_tutorial.ipynb
Checking PEP8 compliance...
Running notebook...
Before:
    "max_epochs = 60\n",
    "max_epochs = 120\n",
After:
    "max_epochs = 1\n",
    "max_epochs = 1\n",
Before:
    "val_interval = 5\n",
    "val_interval = 5\n",
After:
    "val_interval = 1\n",
    "val_interval = 1\n",
Before:
    "num_batches_for_histogram = 200  # sample this many batches\n",
After:
    "num_batches_for_histogram = 1  # sample this many batches\n",
/opt/conda/lib/python3.8/site-packages/papermill/iorw.py:50: FutureWarning: pyarrow.HadoopFileSystem is deprecated as of 2.0.0, please use pyarrow.fs.HadoopFileSystem instead.
  from pyarrow import HadoopFileSystem

Executing:   0%|          | 0/97 [00:00<?, ?cell/s]
Executing:   1%|          | 1/97 [00:01<02:05,  1.31s/cell]
Executing:   4%|▍         | 4/97 [00:09<03:57,  2.55s/cell]
Executing:   5%|▌         | 5/97 [00:11<03:42,  2.42s/cell]
Executing:   9%|▉         | 9/97 [1:50:32<24:52:15, 1017.45s/cell]
Executing:  26%|██▌       | 25/97 [1:50:33<4:30:49, 225.69s/cell] 
Executing:  28%|██▊       | 27/97 [1:50:34<3:51:14, 198.21s/cell]
Executing:  28%|██▊       | 27/97 [1:50:35<4:46:43, 245.76s/cell]
Traceback (most recent call last):
  File "/opt/conda/bin/papermill", line 8, in <module>
    sys.exit(papermill())
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/papermill/cli.py", line 250, in papermill
    execute_notebook(
  File "/opt/conda/lib/python3.8/site-packages/papermill/execute.py", line 122, in execute_notebook
    raise_for_execution_errors(nb, output_path)
  File "/opt/conda/lib/python3.8/site-packages/papermill/execute.py", line 234, in raise_for_execution_errors
    raise error
papermill.exceptions.PapermillExecutionError: 
---------------------------------------------------------------------------
Exception encountered at "In [13]":
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/transforms/transform.py in apply_transform(transform, data, map_items, unpack_items)
     81             return [_apply_transform(transform, item, unpack_items) for item in data]
---> 82         return _apply_transform(transform, data, unpack_items)
     83     except Exception as e:

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/transforms/transform.py in _apply_transform(transform, parameters, unpack_parameters)
     52 
---> 53     return transform(parameters)
     54 

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/transforms/io/dictionary.py in __call__(self, data, reader)
    120         for key, meta_key, meta_key_postfix in self.key_iterator(d, self.meta_keys, self.meta_key_postfix):
--> 121             data = self._loader(d[key], reader)
    122             if self._loader.image_only:

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/transforms/io/array.py in __call__(self, filename, reader)
    215 
--> 216         img_array, meta_data = reader.get_data(img)
    217         img_array = img_array.astype(self.dtype, copy=False)

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/data/image_reader.py in get_data(self, img)
    242         for i in ensure_tuple(img):
--> 243             data = self._get_array_data(i)
    244             img_array.append(data)

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/data/image_reader.py in _get_array_data(self, img)
    327         """
--> 328         np_img = itk.array_view_from_image(img, keep_axes=False)
    329         if img.GetNumberOfComponentsPerPixel() == 1:  # handling spatial images

/opt/conda/lib/python3.8/site-packages/itk/support/extras.py in GetArrayViewFromImage(image_or_filter, keep_axes, update, ttype)
    323     """Get an array view with the content of the image buffer"""
--> 324     return _GetArrayFromImage(
    325         image_or_filter, "GetArrayViewFromImage", keep_axes, update, ttype

/opt/conda/lib/python3.8/site-packages/itk/support/extras.py in _GetArrayFromImage(image_or_filter, function_name, keep_axes, update, ttype)
    293         ImageType = img.__class__
--> 294     keys = [k for k in itk.PyBuffer.keys() if k[0] == ImageType]
    295     if len(keys) == 0:

/opt/conda/lib/python3.8/site-packages/itk/support/lazy.py in __getattribute__(self, attr)
    131                     namespace = {}
--> 132                     base.itk_load_swig_module(module, namespace)
    133                     self.loaded_lazy_modules.add(module)

/opt/conda/lib/python3.8/site-packages/itk/support/base.py in itk_load_swig_module(name, namespace)
    109     loader = LibraryLoader()
--> 110     l_module = loader.load(swig_module_name)
    111 

/opt/conda/lib/python3.8/site-packages/itk/support/base.py in load(self, name)
    258             l_spec = importlib.util.find_spec(name)
--> 259             l_spec.loader.exec_module(l_module)  # pytype: disable=attribute-error
    260             return l_module

/opt/conda/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module)

/opt/conda/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/opt/conda/lib/python3.8/site-packages/itk/support/../ITKBridgeNumPyPython.py in <module>
     70 import itk.ITKCommonPython
---> 71 from itk.itkPyBufferPython import *
     72 from itk.itkPyVectorContainerPython import *

/opt/conda/lib/python3.8/site-packages/itk/itkPyBufferPython.py in <module>
    117 try:
--> 118     from distributed.protocol import dask_serialize, dask_deserialize
    119     from typing import Dict, List, Tuple

/opt/conda/lib/python3.8/site-packages/distributed/__init__.py in <module>
      7 from ._version import get_versions
----> 8 from .actor import Actor, ActorFuture
      9 from .client import (

/opt/conda/lib/python3.8/site-packages/distributed/actor.py in <module>
      4 
----> 5 from .client import Future
      6 from .protocol import to_serialize

/opt/conda/lib/python3.8/site-packages/distributed/client.py in <module>
     52 from . import versions as version_module
---> 53 from .batched import BatchedSend
     54 from .cfexecutor import ClientExecutor

/opt/conda/lib/python3.8/site-packages/distributed/batched.py in <module>
      9 
---> 10 from .core import CommClosedError
     11 

/opt/conda/lib/python3.8/site-packages/distributed/core.py in <module>
     23 from . import profile, protocol
---> 24 from .comm import (
     25     CommClosedError,

/opt/conda/lib/python3.8/site-packages/distributed/comm/__init__.py in <module>
     24 
---> 25 _register_transports()

/opt/conda/lib/python3.8/site-packages/distributed/comm/__init__.py in _register_transports()
     16 def _register_transports():
---> 17     from . import inproc, tcp, ws
     18 

/opt/conda/lib/python3.8/site-packages/distributed/comm/tcp.py in <module>
    379 
--> 380 class BaseTCPConnector(Connector, RequireEncryptionMixin):
    381     _executor = ThreadPoolExecutor(2, thread_name_prefix="TCP-Executor")

/opt/conda/lib/python3.8/site-packages/distributed/comm/tcp.py in BaseTCPConnector()
    381     _executor = ThreadPoolExecutor(2, thread_name_prefix="TCP-Executor")
--> 382     _resolver = netutil.ExecutorResolver(close_executor=False, executor=_executor)
    383     client = TCPClient(resolver=_resolver)

/opt/conda/lib/python3.8/site-packages/tornado/util.py in __new__(cls, *args, **kwargs)
    287         # here too.
--> 288         instance.initialize(*args, **init_kwargs)
    289         return instance

/opt/conda/lib/python3.8/site-packages/tornado/netutil.py in initialize(self, executor, close_executor)
    426     ) -> None:
--> 427         self.io_loop = IOLoop.current()
    428         if executor is not None:

/opt/conda/lib/python3.8/site-packages/tornado/ioloop.py in current(instance)
    262         try:
--> 263             loop = asyncio.get_event_loop()
    264         except (RuntimeError, AssertionError):

/opt/conda/lib/python3.8/asyncio/events.py in get_event_loop(self)
    638         if self._local._loop is None:
--> 639             raise RuntimeError('There is no current event loop in thread %r.'
    640                                % threading.current_thread().name)

RuntimeError: There is no current event loop in thread 'Thread-9'.

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_11802/3916465789.py in <module>
----> 1 dataset_seg_available_train = monai.data.CacheDataset(
      2     data=data_seg_available_train,
      3     transform=transform_seg_available,
      4     cache_num=16
      5 )

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/data/dataset.py in __init__(self, data, transform, cache_num, cache_rate, num_workers, progress, copy_cache)
    699         if self.num_workers is not None:
    700             self.num_workers = max(int(self.num_workers), 1)
--> 701         self._cache: List = self._fill_cache()
    702 
    703     def set_data(self, data: Sequence):

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/data/dataset.py in _fill_cache(self)
    720         with ThreadPool(self.num_workers) as p:
    721             if self.progress and has_tqdm:
--> 722                 return list(
    723                     tqdm(
    724                         p.imap(self._load_cache_item, range(self.cache_num)),

/opt/conda/lib/python3.8/site-packages/tqdm/std.py in __iter__(self)
   1178 
   1179         try:
-> 1180             for obj in iterable:
   1181                 yield obj
   1182                 # Update and possibly print the progressbar.

/opt/conda/lib/python3.8/multiprocessing/pool.py in next(self, timeout)
    866         if success:
    867             return value
--> 868         raise value
    869 
    870     __next__ = next                    # XXX

/opt/conda/lib/python3.8/multiprocessing/pool.py in worker(inqueue, outqueue, initializer, initargs, maxtasks, wrap_exception)
    123         job, i, func, args, kwds = task
    124         try:
--> 125             result = (True, func(*args, **kwds))
    126         except Exception as e:
    127             if wrap_exception and func is not _helper_reraises_exception:

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/data/dataset.py in _load_cache_item(self, idx)
    740                 break
    741             _xform = deepcopy(_transform) if isinstance(_transform, ThreadUnsafe) else _transform
--> 742             item = apply_transform(_xform, item)
    743         return item
    744 

/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/transforms/transform.py in apply_transform(transform, data, map_items, unpack_items)
    104             else:
    105                 _log_stats(data=data)
--> 106         raise RuntimeError(f"applying transform {transform}") from e
    107 
    108 

RuntimeError: applying transform <monai.transforms.io.dictionary.LoadImaged object at 0x7f610d679ee0>

wyli avatar Dec 23 '21 15:12 wyli

Seems like related to some ITK logic in the python / native connection? @thewtex , do you have any idea what's going on?

Thanks in advance.

Nic-Ma avatar Dec 24 '21 01:12 Nic-Ma

@wyli catching up here, it looks like you identified the issue. Thanks!

thewtex avatar Dec 29 '21 16:12 thewtex

Sorry I just noticed this issue; was this ultimately resolved? To close this, are we waiting on the change https://github.com/InsightSoftwareConsortium/ITK/pull/3011 to be included in the version of ITK used by MONAI?

ebrahimebrahim avatar Feb 16 '22 13:02 ebrahimebrahim