开心六月综合激情婷婷|欧美精品成人动漫二区|国产中文字幕综合色|亚洲人在线成视频

    1. 
      
        <b id="zqfy3"><legend id="zqfy3"><fieldset id="zqfy3"></fieldset></legend></b>
          <ul id="zqfy3"></ul>
          <blockquote id="zqfy3"><strong id="zqfy3"><dfn id="zqfy3"></dfn></strong></blockquote>
          <blockquote id="zqfy3"><legend id="zqfy3"></legend></blockquote>
          打開APP
          userphoto
          未登錄

          開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

          開通VIP
          Ray 環(huán)境搭建和示例

          文章目錄

          • Ray 環(huán)境搭建和示例
            • Ray 環(huán)境設(shè)置
              • 安裝 Python 3
              • 安裝 Python 虛擬環(huán)境
              • 安裝 Ray
              • 以 Cluster 模式運(yùn)行 Ray
            • 示例
            • 參考

          Ray 環(huán)境設(shè)置

          本次實(shí)驗(yàn)采用 2 臺(tái) Mac,系統(tǒng) macOS Mojave Version 10.14.3。

          安裝 Python 3

          brew install python
          

          安裝 Python 虛擬環(huán)境

          pip3 install virtualenv
          cd ~/Tools
          virtualenv -p /usr/local/bin/python3 git_ray_env
          source ./git_ray/env/bin/active
          

          然后,查看虛擬環(huán)境 Python 的版本

          $ python -V
          Python 3.7.3
          

          注意:確保兩臺(tái)機(jī)器 Python 版本一致。

          安裝 Ray

          pip install ray
          

          Ray 的版本是 0.7.0

          以 Cluster 模式運(yùn)行 Ray

          兩臺(tái)機(jī)器IP分別為:192.168.1.6192.168.1.9

          192.168.1.6 作為 Head,另一臺(tái)作為 Node。

          在 Head 機(jī)器上執(zhí)行:

          ray start --head --redis-port=6379
          

          啟動(dòng)輸入如下:

          2019-06-23 15:04:18,601INFO scripts.py:289 -- Using IP address 192.168.1.6 for this node.
          2019-06-23 15:04:18,602INFO node.py:497 -- Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-06-23_15-04-18_601521_88785/logs.
          2019-06-23 15:04:18,710INFO services.py:409 -- Waiting for redis server at 127.0.0.1:6379 to respond...
          2019-06-23 15:04:18,835INFO services.py:409 -- Waiting for redis server at 127.0.0.1:25445 to respond...
          2019-06-23 15:04:18,840INFO services.py:806 -- Starting Redis shard with 3.44 GB max memory.
          2019-06-23 15:04:18,855INFO node.py:511 -- Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-06-23_15-04-18_601521_88785/logs.
          2019-06-23 15:04:18,856INFO services.py:1441 -- Starting the Plasma object store with 5.15 GB memory using /tmp.
          2019-06-23 15:04:18,877INFO scripts.py:319 --
          Started Ray on this node. You can add additional nodes to the cluster by calling
          
              ray start --redis-address 192.168.1.6:6379
          
          from the node you wish to add. You can connect a driver to the cluster from Python by running
          
              import ray
              ray.init(redis_address="192.168.1.6:6379")
          
          If you have trouble connecting from a different machine, check that your firewall is configured properly. If you wish to terminate the processes that have been started, run
          
              ray stop
          

          在 Node 機(jī)器上執(zhí)行:

          ray start --redis-address=192.168.1.6:6379
          

          啟動(dòng)輸入如下:

          2019-06-23 15:08:37,474INFO services.py:409 -- Waiting for redis server at 192.168.1.6:6379 to respond...
          2019-06-23 15:08:37,503INFO scripts.py:363 -- Using IP address 192.168.1.9 for this node.
          2019-06-23 15:08:37,551INFO node.py:511 -- Process STDOUT and STDERR is being redirected to /tmp/ray/session_2019-06-23_15-04-18_601521_88785/logs.
          2019-06-23 15:08:37,551INFO services.py:1441 -- Starting the Plasma object store with 5.15 GB memory using /tmp.
          2019-06-23 15:08:37,566INFO scripts.py:371 --
          Started Ray on this node. If you wish to terminate the processes that have been started, run
          
              ray stop
          

          示例

          hello_world.py

          import ray
          
          ray.init(redis_address="192.168.1.6:6379")
          
          @ray.remote
          def hello():
              return "Hello"
          
          @ray.remote
          def world():
              return "world!"
          
          @ray.remote
          def hello_world(a, b):
              return a + " " + b
          
          a_id = hello.remote()
          b_id = world.remote()
          c_id = hello_world.remote(a_id, b_id)
          
          hello = ray.get(c_id)
          
          print(hello)
          

          運(yùn)行:python hello_world.py

          輸出:

          Hello world!
          

          參考

          1. 伯克利AI分布式框架Ray,兼容TensorFlow、PyTorch與MXNet
          本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
          打開APP,閱讀全文并永久保存 查看更多類似文章
          猜你喜歡
          類似文章
          Ray
          6.面向大數(shù)據(jù) AI的語言
          取代Python多進(jìn)程!伯克利開源分布式框架Ray
          Redis服務(wù)之常用配置(三)
          redis 集群(文檔整理)
          令人抓狂的redis和rediscluster Python驅(qū)動(dòng)包的安裝
          更多類似文章 >>
          生活服務(wù)
          分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
          綁定賬號(hào)成功
          后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
          如果VIP功能使用有故障,
          可點(diǎn)擊這里聯(lián)系客服!

          聯(lián)系客服