imaris / ImarisWriter

Apache License 2.0
28 stars 13 forks source link

PyImarisWriter - Issues with pip install on Windows 10 #4

Closed carshadi closed 2 years ago

carshadi commented 2 years ago

Hello,

I have installed PyImarisWriter via pip on Windows 10. There is inconsistent behavior with PyImarisWriterNumpyExample.py. If I run this test repeatedly, it will run fine on some runs, then hang on others. For example, it stalled on the last line below:

User Progress 16, Bytes written: 11599
User Progress 33, Bytes written: 18016
User Progress 50, Bytes written: 27617
User Progress 66, Bytes written: 31783
User Progress 83, Bytes written: 36307
User Progress 100, Bytes written: 41939
Wrote uint8 image from uint8 numpy array to PyImarisWriterNumpyExample0.ims
User Progress 12, Bytes written: 8394
User Progress 25, Bytes written: 15188
User Progress 37, Bytes written: 23105
User Progress 50, Bytes written: 29710
User Progress 62, Bytes written: 38102
User Progress 75, Bytes written: 45180
User Progress 87, Bytes written: 54141
User Progress 100, Bytes written: 62084

Note that it always hangs after finishing a block, so the issue may be with the PW.ImageConverter.Finish or PW.ImageConverter.Destroy methods https://github.com/imaris/ImarisWriterTest/blob/2de64e247964eec9e85c89b4a39c9852c046d1e0/testPy/PyImarisWriterNumpyExample.py#L123-L125

Additionally, when testing on a larger dataset, I will randomly get the following error.

Traceback (most recent call last):
  File "C:/Users/cameron.arshadi/Desktop/repos/lightsheet-compression-tests/compress_h5.py", line 192, in <module>
    main()
  File "C:/Users/cameron.arshadi/Desktop/repos/lightsheet-compression-tests/compress_h5.py", line 175, in main
    bytes_written, compress_time= run(test_config, np_data.astype(test_config.mNp_type), nCores)
  File "C:/Users/cameron.arshadi/Desktop/repos/lightsheet-compression-tests/compress_h5.py", line 120, in run
    converter.Destroy()
  File "C:\Users\cameron.arshadi\Miniconda3\envs\lightsheet-compression-pyimagej\lib\site-packages\PyImarisWriter\PyImarisWriter.py", line 584, in Destroy
    self._check_errors('bpImageConverterC_Destroy')
  File "C:\Users\cameron.arshadi\Miniconda3\envs\lightsheet-compression-pyimagej\lib\site-packages\PyImarisWriter\PyImarisWriter.py", line 361, in _check_errors
    last_exception = self.mcdll.bpImageConverterC_GetLastException(self.mImageConverterPtr)
OSError: exception: access violation reading 0xFFFFFFFFFFFF0019

Either the hang or the above error will occur, but never both.

Output of systeminfo

OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.19042 N/A Build 19042
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:
Registered Organization:
Original Install Date:     12/17/2021, 1:08:59 PM
System Boot Time:          3/14/2022, 8:19:57 PM
System Manufacturer:       LENOVO
System Model:              20T00034US
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 6 Model 142 Stepping 12 GenuineIntel ~1803 Mhz
BIOS Version:              LENOVO N2YET20W (1.09 ), 7/1/2020
Windows Directory:         C:\windows
System Directory:          C:\windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory:     16,136 MB
Available Physical Memory: 8,543 MB
Virtual Memory: Max Size:  20,062 MB
Virtual Memory: Available: 6,974 MB
Virtual Memory: In Use:    13,088 MB
Page File Location(s):     C:\pagefile.sys
Hotfix(s):                 8 Hotfix(s) Installed.
                           [01]: KB5007289
                           [02]: KB4562830
                           [03]: KB4570334
                           [04]: KB4577586
                           [05]: KB4580325
                           [06]: KB5008212
                           [07]: KB5007273
                           [08]: KB5005260
Hyper-V Requirements:      VM Monitor Mode Extensions: Yes
                           Virtualization Enabled In Firmware: Yes
                           Second Level Address Translation: Yes
                           Data Execution Prevention Available: Yes
SachaGuyer commented 2 years ago

Hi,

Thank you for reporting this. There is indeed an error in PyImarisWriter in the Destroy method:

Calling bpImageConverterC_Destroy(bpImageConverterCPtr aImageConverterC) deletes the bpImageConverterCPtr argument, which then should not be used afterwards. However, PyImarisWriter uses it in the _check_errors method.

This has been fixed with this pull request. The PyImarisWriter package on the Python Package Index will be updated at some point in the future.

carshadi commented 2 years ago

Awesome, this is great. thanks a ton!

Poofjunior commented 1 year ago

Whoop--it looks like the prior version on PyPI has yet to be updated.