question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot change `jax_platform_name` on the fly

See original GitHub issue

I am using jax.config.update('jax_platform_name', 'cpu') to change the device placement.

import jax
import jax.numpy as np
a = np.zeros((128, 128))
print(a.device())  # TPU
jax.config.update('jax_platform_name', 'cpu')
a = np.zeros((128, 128))
print(a.device())  # TPU, expected CPU

Related: #8879

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ayaka14732commented, Oct 12, 2022

@theovincent

The correct way is:

import jax
import jax.numpy as jnp

print(jnp.ones(3).device())

with jax.default_device(jax.devices('cpu')[0]):
    print(jnp.ones(3).device()) 
2reactions
hawkinspcommented, Apr 19, 2022

jax_platform_name isn’t intended to be set at run time. I suspect what you actually want to control is the default device placement, for which @skye was adding a context-manager-like API.

(I don’t believe it landed yet, though.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

JAX Frequently Asked Questions (FAQ)
If you have a Python function that changes behavior after using jax.jit() , perhaps your function uses global state, or has side-effects.
Read more >
jax rs service on wildfly doesn't seem reachable?
You can go to wildfly administration console and have a look in Deployments section what context path is your deployed application available at....
Read more >
2 Oracle WebLogic Server
Change the order of the network cards in the machine so that the card with the actual node's host name is Card 1....
Read more >
Beyond Van Gogh Jacksonville: The Immersive Experience
Jacksonville, prepare yourself for the most immersive experience. purchase tickets ... Location. Immersive Art Space 712 N Hogan St, Jacksonville, FL 32202 ...
Read more >
I can't breathe. - Citi Blog
Citi bank can go the way of the NBA. Reply. avatar. Antonio. Ok. You are a corporation that's using tragedy to imply you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found