-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update v6e-256 KubeRay Sample (#2466)
* Update v6e-256 sample Signed-off-by: Ryan O'Leary <[email protected]> * Remove multi-slice env vars and block on Jax call Signed-off-by: Ryan O'Leary <[email protected]> * Add multihost_utils import Signed-off-by: Ryan O'Leary <[email protected]> * Add print statement Signed-off-by: Ryan O'Leary <[email protected]> * Print TPU_WORKER_ID Signed-off-by: Ryan O'Leary <[email protected]> * Fix print Signed-off-by: Ryan O'Leary <[email protected]> * move barrier after jax device_count call Signed-off-by: Ryan O'Leary <[email protected]> * Add missing import Signed-off-by: Ryan O'Leary <[email protected]> * test using sleep for RayJob Signed-off-by: Ryan O'Leary <[email protected]> * Clean up tpu_list_devices script Signed-off-by: Ryan O'Leary <[email protected]> * Remove securityContext from spec Signed-off-by: Ryan O'Leary <[email protected]> * Remove privileged security context Signed-off-by: ryanaoleary <[email protected]> * Remove unneeded securityContexts Signed-off-by: ryanaoleary <[email protected]> * Add back in sync_global_devices Signed-off-by: ryanaoleary <[email protected]> --------- Signed-off-by: Ryan O'Leary <[email protected]> Signed-off-by: ryanaoleary <[email protected]>
- Loading branch information
1 parent
4fc1799
commit b9f0209
Showing
5 changed files
with
11 additions
and
21 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
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,12 +1,20 @@ | ||
import os | ||
import ray | ||
import jax | ||
import time | ||
|
||
from jax.experimental import multihost_utils | ||
|
||
ray.init() | ||
|
||
@ray.remote(resources={"TPU": 4}) | ||
def tpu_cores(): | ||
return "TPU cores:" + str(jax.device_count()) | ||
multihost_utils.sync_global_devices("sync") | ||
cores = "TPU cores:" + str(jax.device_count()) | ||
print("TPU Worker: " + os.environ.get("TPU_WORKER_ID")) | ||
return cores | ||
|
||
num_workers = int(ray.available_resources()["TPU"]) // 4 | ||
print(f"Number of TPU Workers: {num_workers}") | ||
result = [tpu_cores.remote() for _ in range(num_workers)] | ||
print(ray.get(result)) |