Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Building jaxlib (cpu) with threading disabled? #11168

Open
josephrocca opened this issue Jun 19, 2022 Discussed in #11130 · 1 comment
Open

Feature request: Building jaxlib (cpu) with threading disabled? #11168

josephrocca opened this issue Jun 19, 2022 Discussed in #11130 · 1 comment
Labels
contributions welcome The JAX team has not prioritized work on this. Community contributions are welcome. enhancement New feature or request

Comments

@josephrocca
Copy link
Contributor

Discussed in #11130

Originally posted by josephrocca June 17, 2022
Hello, I'm currently trying to get JAX (cpu only) working in the browser. This requires compiling with Emscripten, and apparently I need to compile without threading.

IIUC it's possible to restrict JAX to a single thread at run time, but I wasn't able to find any info on compiling without threading.

I'm wondering if there's a flag for this that I can set somewhere? If not, is there any viable (even if very hacky) way to do it?

Thanks!

@zhangqiaorjc
Copy link
Member

@josephrocca do you mean compiling without any references to threading? I don't think that's easily doable in JAX.

If you just want fewer threads, there might need to be a few source-level changes possible

  1. tfrt::CreateMultiThreadedWorkQueue(1, 1)

https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/compiler/xla/pjrt/tfrt_cpu_pjrt_client.cc;l=133-135?q=tfrt_cpu_pjrt_client&ss=tensorflow

  1. Set env var NPROC=1

https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/compiler/xla/pjrt/utils.cc;l=272?q=DefaultThreadPoolSize&ss=tensorflow

Note that you'd need to re-compile jaxlib from source.
https://jax.readthedocs.io/en/latest/developer.html#building-jaxlib-from-source

But even these won't get you to exactly 1 thread.

@zhangqiaorjc zhangqiaorjc added the contributions welcome The JAX team has not prioritized work on this. Community contributions are welcome. label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome The JAX team has not prioritized work on this. Community contributions are welcome. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants