Skip to content

Instantly share code, notes, and snippets.

@michaelchughes
Created November 29, 2022 00:03
Show Gist options
  • Save michaelchughes/363f9bf62631dfa37fbf1f402d975f56 to your computer and use it in GitHub Desktop.
Save michaelchughes/363f9bf62631dfa37fbf1f402d975f56 to your computer and use it in GitHub Desktop.
Simple script that verifies JAX has access to GPU and can do basic ops (matrix multiply)
import jax
import jax.numpy as jnp
if __name__ == '__main__':
print("jax.devices()")
print(jax.devices())
a = jnp.asarray([[1.0, 2.0, 3.0], [4., 5., 6.]])
b = jnp.asarray([[1.0, 2.0], [3.0, 4.0], [5., 6.]])
print("Array 'a':")
print(a)
print("Array 'b':")
print(b)
print("where do the arrays live?")
print(a.device_buffer.device())
print("Result of jnp.dot(a,b)")
c = jnp.dot(a,b)
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment