Ray with JupyterHub

ODP 3.3.6.4-1 introduces Ray, a “framework for scaling AI and Python applications.

Example:

import ray import time ray.init() items = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" ] def get_item(idx: int): time.sleep(idx / 10.) return idx, items[idx] @ray.remote def retrieve_task(item): return get_item(item) def print_runtime(data, start_time): print(f"Runtime: {time.time() - start_time:.2f} seconds, data: ") print(*data, sep="\n") start = time.time() data = [get_item(item) for item in range(len(items))] print("Time to do it the synchronous way:") print_runtime(data, start) start = time.time() object_refs = [ retrieve_task.remote(item) for item in range(len(items))] data = ray.get(object_refs) print("Time to do it with ray:") print_runtime(data, start)

Which gives the following output:




  Last updated
On This Page
Ray with JupyterHub