Problem Import ForkContext

Problem Import ForkContext  

  By: antoniosantos on March 4, 2022, 12:45 a.m.

Dear ones, good night.

I'd like to ask you a simple question. How would i solve this ForkContext import issue that I'm not getting.

The following error appears: (https://drive.google.com/file/d/1l3VBBDAbVP1sYbYhBAKgWOPa347uyY-v/view?usp=sharing)

My system is win32 apparently, because the code is not processed in that part. (https://drive.google.com/file/d/1M1u4aYqyWrJPchl6wDAWrMd9GKk0Z8M0/view?usp=sharing)

Could someone give me a hand?

Re: Problem Import ForkContext  

  By: mart.vanrijthoven on March 4, 2022, 10:47 a.m.

Dear Antônio Santos,

Thanks for notifying me about this problem.

The problem you have is related to the concurrent buffer package used in wholeslidedata. The error resulted due to importing ForkContext without checking the current platform. The ForkContext is not available on windows. I have updated this package to check the platform before importing. Please remove and install concurrent buffer again:

pip uninstall concurrentbuffer pip install concurrentbuffer==0.0.6

Please note that the wholeslidedata package is not actively tested on windows. Though, I think there should be no reason why it would not work on windows.

Also, note that in the create_batch_iterator function, the standard context is 'fork', Please change it to 'spawn' when working on windows.

Re: Problem Import ForkContext  

  By: martadiez87654 on March 9, 2022, 10:24 a.m.

Hello antoniosantos,

I am having the same problem as you with windows. I followed the steps in the answer and it is still not working, I receive the same error.

Did it solve your problem?

Marta

 Last edited by: martadiez87654 on Aug. 15, 2023, 12:56 p.m., edited 1 time in total.

Re: Problem Import ForkContext  

  By: mart.vanrijthoven on March 9, 2022, 10:52 a.m.

Dear Marta,

I am sorry to hear that you also have the same problem on windows. Can you please post your full error traceback?

Best wishes, Mart

Re: Problem Import ForkContext  

  By: martadiez87654 on March 9, 2022, 11:24 a.m.

Hello,

I am following the notebook "Tiger - HookNet training.ipynb". My error comes when I try to import create_batch_iterator from wholeslidedata.iterators in Windows. The error is: "ImportError: cannot import name 'ForkContext' from 'multiprocessing.context'")

The solution you provided is to check that concurrentbuffer==0.0.6, but in my case "Requirement already satisfied: concurrentbuffer==0.0.6"

Later, when importation is completed, I will change my context from "fork" to "spawn", as in the following line: "with create_batch_iterator(mode=mode, user_config=user_config, cpus=cpus, context="spawn") as training_batch_iterator: pprint(training_batch_iterator.dataset.annotations_per_label_per_key)"

https://drive.google.com/file/d/1lQHlkoPuZa42c5lJqS_Iy1mXr0eE_h52/view?usp=sharing https://drive.google.com/file/d/1h14ZkBF6SZ6sfG0fYrHPhteas8yF4kL3/view?usp=sharing https://drive.google.com/file/d/1A3Usjijw5Y8p1i7dvc2hsWrIJJC7G_4T/view?usp=sharing

I am having a similar porblem with "Tiger - BatchIterator Detection.ipynb" as I also have to use create_batch_iterator

Thanks in advance,

Marta

 Last edited by: martadiez87654 on Aug. 15, 2023, 12:56 p.m., edited 3 times in total.

Re: Problem Import ForkContext  

  By: mart.vanrijthoven on March 9, 2022, 11:27 a.m.

Dear Antônio and Marta,

I think i now what the problem was. I forget to check for windows in another file. I am not able to test the package on windows.

Could you please the new version:

pip uninstall concurrentbuffer pip install concurrentbuffer==0.0.7

Best wishes, Mart

Re: Problem Import ForkContext  

  By: mart.vanrijthoven on March 9, 2022, 11:36 a.m.

Dear Marta,

Thanks for the information!

I can not seem to open this image: https://drive.google.com/file/d/1lQHlkoPuZa42c5lJqSIy1mXr0eEh52/view?usp=sharing

Though, I hope all the errors will go away with then new 0.0.7 version. Please let me know if it is still not working.

Best wishes, Mart