Esempio n. 1
0
def init_ray_context_fixture():
    from bigdl.dllib.nncontext import init_spark_on_local
    from bigdl.orca.ray import RayContext
    sc = init_spark_on_local(cores=4, spark_log_level="INFO")
    ray_ctx = RayContext(sc=sc, object_store_memory="1g")
    ray_ctx.init()
    yield
    ray_ctx.stop()
    sc.stop()
Esempio n. 2
0
    def test_local(self):
        @ray.remote
        class TestRay:
            def hostname(self):
                import socket
                return socket.gethostname()

        sc = init_spark_on_local(cores=8)
        ray_ctx = RayContext(sc=sc,
                             object_store_memory="1g",
                             ray_node_cpu_cores=4)
        address_info = ray_ctx.init()
        assert "object_store_address" in address_info
        actors = [TestRay.remote() for i in range(0, 4)]
        print(ray.get([actor.hostname.remote() for actor in actors]))
        ray_ctx.stop()
        sc.stop()
 def test_local(self):
     node_num = 4
     sc = init_spark_on_local(cores=node_num)
     ray_ctx = RayContext(sc=sc, object_store_memory="1g")
     ray_ctx.init()
     actors = [TestRay.remote() for i in range(0, node_num)]
     print(ray.get([actor.hostname.remote() for actor in actors]))
     ray_ctx.stop()
     time.sleep(3)
     # repeat
     print("-------------------first repeat begin!------------------")
     ray_ctx = RayContext(sc=sc, object_store_memory="1g")
     ray_ctx.init()
     actors = [TestRay.remote() for i in range(0, node_num)]
     print(ray.get([actor.hostname.remote() for actor in actors]))
     ray_ctx.stop()
     sc.stop()
     time.sleep(3)
     for process_info in ray_ctx.ray_processesMonitor.process_infos:
         for pid in process_info.pids:
             assert not psutil.pid_exists(pid)
Esempio n. 4
0
@ray.remote
class TestRay():
    def hostname(self):
        import socket
        return socket.gethostname()

    def check_cv2(self):
        # conda install -c conda-forge opencv==3.4.2
        import cv2
        return cv2.__version__

    def ip(self):
        return ray._private.services.get_node_ip_address()

    def network(self):
        from urllib.request import urlopen
        try:
            urlopen('http://www.baidu.com', timeout=3)
            return True
        except Exception as err:
            return False


actors = [TestRay.remote() for i in range(0, slave_num)]
print(ray.get([actor.hostname.remote() for actor in actors]))
print(ray.get([actor.ip.remote() for actor in actors]))
# print(ray.get([actor.network.remote() for actor in actors]))

ray_ctx.stop()