loguru icon indicating copy to clipboard operation
loguru copied to clipboard

RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock. self.pid = os.fork()

Open melikaaala opened this issue 1 year ago • 9 comments

Hi I have trained machine learning python code on google colab but I faced this error. Is there any solution for this: os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock. self.pid = os.fork()

melikaaala avatar Apr 16 '24 05:04 melikaaala

Can you please share the code that produces this warning?

Loguru does not call os.fork().

Delgan avatar Apr 16 '24 05:04 Delgan

I use this url: https://github.com/Algolzw/image-restoration-sde

melikaaala avatar Apr 16 '24 09:04 melikaaala

hi I use this code: https://github.com/Algolzw/image-restoration-sde

On Tue, Apr 16, 2024 at 9:29 AM Delgan @.***> wrote:

Can you please share the code that produces this warning?

Loguru does not call os.fork().

— Reply to this email directly, view it on GitHub https://github.com/Delgan/loguru/issues/1125#issuecomment-2058288286, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALIF3BCCZTOHLUSXTG3NVR3Y5S43HAVCNFSM6AAAAABGISM4LSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJYGI4DQMRYGY . You are receiving this because you authored the thread.Message ID: @.***>

melikaaala avatar Apr 17 '24 15:04 melikaaala

Sorry but there is not enough information for me to help you. Please, try to provide a minimal reproducible example involving usage of Loguru.

Right now, I don't understand how the problem you're facing is related to Loguru. As I said, your error is complaining about usage of os.fork() within JAX framework, but Loguru does not make any use of forking.

Delgan avatar Apr 17 '24 17:04 Delgan

this bug still exists in tf 2.16.1

steveepreston avatar Aug 24 '24 08:08 steveepreston

Ensure that you have the latest version of JAX installed. There may be fixes in more recent versions that address these issues. You can upgrade JAX and its dependencies as follows:

pip install --upgrade jax jaxlib

MAJK1988 avatar Sep 14 '24 07:09 MAJK1988

I have the same warning bruh, I run on VSC using ubuntu server (with 2 GPU). Has anyone ever been in this same situation as me? Pls help me!!!!!!! Thanks a bunch!

LeeTunMT avatar Dec 20 '24 09:12 LeeTunMT

@LeeTunMT Would it be possible for you to please provide a minimal reproducible example so that I can investigate the problem?

Delgan avatar Dec 30 '24 18:12 Delgan

Hi there, I just came across this issue. The issue you are facing is not related to Loguru at all. The multiprocessing functionality of torch dataloaders (when the num_workers is set to more than 1), torch uses the os.fork in the backend for dataloading. And JAX also uses it by default. So, if you have more than one worker for data preprocessing (which is quite useful when you want to remove the data preprocessing bottleneck), the issue arises. You should set the number of workers to 1 when working with JAX or use another dataloader (maybe use a custom one, I haven't used other alternatives). Hope it helps. Also note that if you are using someone else's code, they probably have this num_workers set to 8 or something, which is a popular option, so you might need to deep dive into the existing source code.

abdullaakhundzada avatar Apr 20 '25 14:04 abdullaakhundzada