-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix v6e TPU Scripts and RayJob CRs (#2447)
- Loading branch information
1 parent
175a1f7
commit 047699f
Showing
3 changed files
with
7 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
import ray | ||
import jax | ||
|
||
ray.init( | ||
runtime_env={ | ||
"pip": [ | ||
"jax[tpu]==0.4.33", | ||
"-f https://storage.googleapis.com/jax-releases/libtpu_releases.html", | ||
] | ||
} | ||
) | ||
ray.init() | ||
|
||
@ray.remote(resources={"TPU": 4}) | ||
def tpu_cores(): | ||
import jax | ||
return "TPU cores:" + str(jax.device_count()) | ||
|
||
num_workers = int(os.environ['TPU_HOSTS']) # Set in env of RayJob or RayCluster. | ||
num_workers = int(ray.available_resources()["TPU"]) // 4 | ||
result = [tpu_cores.remote() for _ in range(num_workers)] | ||
print(ray.get(result)) |