Deadlock condition in layoutlmv2 using OMP library
Author: Agarwal-Saurabh
Pull request: no

I tried to fork the layoutlmv2 model using kserve workers adding the OMP library variables but it leads to deadlock. Intresting fact is it works well without OMP library variables but gives really high inference time.

Is there a resolution to utilize layoutlmv2 with multithreading and forking

sharing the values used for OPEN_MP
os.environ['OMP_NUM_THREADS'] = '4'
os.environ['OMP_PROC_BIND'] = 'false'
os.environ['OMP_SCHEDULE'] = 'STATIC'
os.environ['KMP_AFFINITY']='granularity=fine,compact,1,0'

Comments:
Hi @Agarwal-Saurabh, thanks for reporting this issue. 

So that we can best help, could you follow the issue template and give information about the running environment (from running `transformers-cli env`) and a reproducible code snippet? 

@amyeroberts here is the details
- `transformers` version: 4.28.1
- Platform: Linux-5.4.0-139-generic-x86_64-with-glibc2.2.5
- Python version: 3.8.5
- Huggingface_hub version: 0.13.4
- Safetensors version: not installed
- PyTorch version (GPU?): 1.8.0 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: yes

@Agarwal-Saurabh Thank you. Could you also share a minimal code snippet to reproduce the issue? 

Its not in the model rather in the preprocessor that we are loading to
tokenize for layoulmv2 model

On Wed, 19 Apr 2023, 8:03 pm amyeroberts, ***@***.***> wrote:

> @Agarwal-Saurabh <https://github.com/Agarwal-Saurabh> Thank you. Could
> you also share a minimal code snippet to reproduce the issue?
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/22851#issuecomment-1514847613>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFSMGBGG3MASQ3OFELFA4I3XB7ZTBANCNFSM6AAAAAAXDUJ2KM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>


@Agarwal-Saurabh Without knowing what code you're running and more information about the deadlock behaviour, I'm unable to understand or help with this issue.

@amyeroberts similar issue caught in other processors as well. Here is the code snippet requested https://gist.github.com/harshyadav17/149f1c990c17111d8340fcf2e89a5b88

reference issue : https://github.com/huggingface/transformers/issues/22978

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

This is not solved yet

On Fri, 19 May 2023, 8:32 pm github-actions[bot], ***@***.***>
wrote:

> This issue has been automatically marked as stale because it has not had
> recent activity. If you think this still needs to be addressed please
> comment on this thread.
>
> Please note that issues that do not follow the contributing guidelines
> <https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md>
> are likely to be ignored.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/22851#issuecomment-1554722971>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFSMGBG3TCVG62RD6HZX64TXG6DQBANCNFSM6AAAAAAXDUJ2KM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>


This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.