8000 GitHub - mariodoebler/ray: An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
forked from ray-project/ray

An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.

License

Notifications You must be signed in to change notification settings

mariodoebler/ray

{"props":{"initialPayload":{"allShortcutsEnabled":false,"path":"/","repo":{"id":308274761,"defaultBranch":"master","name":"ray","ownerLogin":"mariodoebler","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2020-10-29T09:14:15.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/43860489?v=4","public":true,"private":false,"isOrgOwned":false},"currentUser":null,"refInfo":{"name":"master","listCacheKey":"v0:1615328777.180817","canEdit":false,"refType":"branch","currentOid":"35f7d84dbe0c4c2bfe8117727eeda5256fe2c3a2"},"tree":{"items":[{"name":".github","path":".github","contentType":"directory"},{"name":"bazel","path":"bazel","contentType":"directory"},{"name":"ci","path":"ci","contentType":"directory"},{"name":"cpp","path":"cpp","contentType":"directory"},{"name":"dashboard","path":"dashboard","contentType":"directory"},{"name":"doc","path":"doc","contentType":"directory"},{"name":"docker","path":"docker","contentType":"directory"},{"name":"java","path":"java","contentType":"directory"},{"name":"python","path":"python","contentType":"directory"},{"name":"release","path":"release","contentType":"directory"},{"name":"rllib","path":"rllib","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"streaming","path":"streaming","contentType":"directory"},{"name":"thirdparty","path":"thirdparty","contentType":"directory"},{"name":".bazelrc","path":".bazelrc","contentType":"file"},{"name":".clang-format","path":".clang-format","contentType":"file"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".flake8","path":".flake8","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".style.yapf","path":".style.yapf","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"BUILD.bazel","path":"BUILD.bazel","contentType":"file"},{"name":"CONTRIBUTING.rst","path":"CONTRIBUTING.rst","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.rst","path":"README.rst","contentType":"file"},{"name":"WORKSPACE","path":"WORKSPACE","contentType":"file"},{"name":"build-docker.sh","path":"build-docker.sh","contentType":"file"},{"name":"build.sh","path":"build.sh","contentType":"file"},{"name":"pylintrc","path":"pylintrc","contentType":"file"},{"name":"scripts","path":"scripts","contentType":"symlink_directory"},{"name":"setup_hooks.sh","path":"setup_hooks.sh","contentType":"file"}],"templateDirectorySuggestionUrl":null,"readme":null,"totalCount":31,"showBranchInfobar":true},"fileTree":null,"fileTreeProcessingTime":null,"foldersToFetch":[],"treeExpanded":false,"symbolsExpanded":false,"isOverview":true,"overview":{"banners":{"shouldRecommendReadme":false,"isPersonalRepo":false,"showUseActionBanner":false,"actionSlug":null,"actionId":null,"showProtectBranchBanner":false,"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_repo","releasePath":"/mariodoebler/ray/releases/new?marketplace=true","showPublishActionBanner":false},"interactionLimitBanner":null,"showInvitationBanner":false,"inviterName":null,"actionsMigrationBannerInfo":{"releaseTags":[],"showImmutableActionsMigrationBanner":false,"initialMigrationStatus":null}},"codeButton":{"contactPath":"/contact","isEnterprise":false,"local":{"protocolInfo":{"httpAvailable":true,"sshAvailable":null,"httpUrl":"https://github.com/mariodoebler/ray.git","showCloneWarning":null,"sshUrl":null,"sshCertificatesRequired":null,"sshCertificatesAvailable":null,"ghCliUrl":"gh repo clone mariodoebler/ray","defaultProtocol":"http","newSshKeyUrl":"/settings/ssh/new","setProtocolPath":"/users/set_protocol"},"platformInfo":{"cloneUrl":"https://desktop.github.com","showVisualStudioCloneButton":false,"visualStudioCloneUrl":"https://windows.github.com","showXcodeCloneButton":false,"xcodeCloneUrl":"xcode://clone?repo=https%3A%2F%2Fgithub.com%2Fmariodoebler%2Fray","zipballUrl":"/mariodoebler/ray/archive/refs/heads/master.zip"}},"newCodespacePath":"/codespaces/new?hide_repo_select=true\u0026repo=308274761"},"popovers":{"rename":null,"renamedParentRepo":null},"commitCount":"6,669","overviewFiles":[{"displayName":"README.rst","repoName":"ray","refName":"master","path":"README.rst","preferredFileType":"readme","tabName":"README","richText":"\u003carticle class=\"markdown-body entry-content container-lg\" itemprop=\"text\"\u003e\u003cp dir=\"auto\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png\"\u003e\u003cimg alt=\"https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png\" src=\"https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003ca href=\"http://docs.ray.io/en/master/?badge=master\" rel=\"nofollow\"\u003e\u003cimg alt=\"https://readthedocs.org/projects/ray/badge/?version=master\" src=\"https://camo.githubusercontent.com/7f5465690b415bb620cf8500a452603fbe5ea23e8b9801740b88f3000431151f/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f7261792f62616467652f3f76657273696f6e3d6d6173746572\" data-canonical-src=\"https://readthedocs.org/projects/ray/badge/?version=master\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://forms.gle/9TSdDYUgxYs8SA9e8\" rel=\"nofollow\"\u003e\u003cimg alt=\"https://img.shields.io/badge/Ray-Join%20Slack-blue\" src=\"https://camo.githubusercontent.com/94d9ec8e23284e1632c0906b67ef87507391fd583e08e974af6b60b931333309/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5261792d4a6f696e253230536c61636b2d626c7565\" data-canonical-src=\"https://img.shields.io/badge/Ray-Join%20Slack-blue\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003ca href=\"https://discuss.ray.io/\" rel=\"nofollow\"\u003e\u003cimg alt=\"https://img.shields.io/badge/Discuss-Ask%20Questions-blue\" src=\"https://camo.githubusercontent.com/0da1a186dc1d8eeec17037d891e3a9f803aaea47ce024b13ec2fa271bede9707/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446973637573732d41736b2532305175657374696f6e732d626c7565\" data-canonical-src=\"https://img.shields.io/badge/Discuss-Ask%20Questions-blue\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\n\u003cdiv dir=\"auto\"\u003e\n\u003cdiv dir=\"auto\"\u003e\u003cbr\u003e\u003c/div\u003e\n\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003cstrong\u003eRay provides a simple, universal API for building distributed applications.\u003c/strong\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eRay is packaged with the following libraries for accelerating machine learning workloads:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://docs.ray.io/en/master/tune.html\" rel=\"nofollow\"\u003eTune\u003c/a\u003e: Scalable Hyperparameter Tuning\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://docs.ray.io/en/master/rllib.html\" rel=\"nofollow\"\u003eRLlib\u003c/a\u003e: Scalable Reinforcement Learning\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://docs.ray.io/en/master/raysgd/raysgd.html\" rel=\"nofollow\"\u003eRaySGD\u003c/a\u003e: Distributed Training Wrappers\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://docs.ray.io/en/master/serve/index.html\" rel=\"nofollow\"\u003eRay Serve\u003c/a\u003e: Scalable and Programmable Serving\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eThere are also many \u003ca href=\"https://docs.ray.io/en/master/ray-libraries.html\" rel=\"nofollow\"\u003ecommunity integrations\u003c/a\u003e with Ray, including \u003ca href=\"https://docs.ray.io/en/master/dask-on-ray.html\" rel=\"nofollow\"\u003eDask\u003c/a\u003e, \u003ca href=\"https://docs.ray.io/en/master/mars-on-ray.html\" rel=\"nofollow\"\u003eMARS\u003c/a\u003e, \u003ca href=\"https://github.com/modin-project/modin\"\u003eModin\u003c/a\u003e, \u003ca href=\"https://horovod.readthedocs.io/en/stable/ray_include.html\" rel=\"nofollow\"\u003eHorovod\u003c/a\u003e, \u003ca href=\"https://huggingface.co/transformers/main_classes/trainer.html#transformers.Trainer.hyperparameter_search\" rel=\"nofollow\"\u003eHugging Face\u003c/a\u003e, \u003ca href=\"/mariodoebler/ray/blob/master/joblib.html\"\u003eScikit-learn\u003c/a\u003e, and others. Check out the \u003ca href=\"https://docs.ray.io/en/master/ray-libraries.html\" rel=\"nofollow\"\u003efull list of Ray distributed libraries here\u003c/a\u003e.\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eInstall Ray with: \u003ccode\u003epip install ray\u003c/code\u003e. For nightly wheels, see the\n\u003ca href=\"https://docs.ray.io/en/master/installation.html\" rel=\"nofollow\"\u003eInstallation page\u003c/a\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-quick-start\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eQuick Start\u003c/h2\u003e\u003ca id=\"user-content-quick-start\" class=\"anchor\" aria-label=\"Permalink: Quick Start\" href=\"#quick-start\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eExecute Python functions in parallel.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import ray\nray.init()\n\n@ray.remote\ndef f(x):\n return x * x\n\nfutures = [f.remote(i) for i in range(4)]\nprint(ray.get(futures))\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003einit\u003c/span\u003e()\n\n\u003cspan class=\"pl-en\"\u003e@\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ef\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ex\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003efutures\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e [\u003cspan class=\"pl-s1\"\u003ef\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003ei\u003c/span\u003e) \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ei\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-en\"\u003erange\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e4\u003c/span\u003e)]\n\u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eget\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003efutures\u003c/span\u003e))\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eTo use Ray's actor model:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import ray\nray.init()\n\n@ray.remote\nclass Counter(object):\n def __init__(self):\n self.n = 0\n\n def increment(self):\n self.n += 1\n\n def read(self):\n return self.n\n\ncounters = [Counter.remote() for i in range(4)]\n[c.increment.remote() for c in counters]\nfutures = [c.read.remote() for c in counters]\nprint(ray.get(futures))\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003einit\u003c/span\u003e()\n\n\u003cspan class=\"pl-en\"\u003e@\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003eclass\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eCounter\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eobject\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__init__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003en\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e\n\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eincrement\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003en\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e+=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e\n\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eread\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003en\u003c/span\u003e\n\n\u003cspan class=\"pl-s1\"\u003ecounters\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e [\u003cspan class=\"pl-v\"\u003eCounter\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e() \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ei\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-en\"\u003erange\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e4\u003c/span\u003e)]\n[\u003cspan class=\"pl-s1\"\u003ec\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eincrement\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e() \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ec\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ecounters\u003c/span\u003e]\n\u003cspan class=\"pl-s1\"\u003efutures\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e [\u003cspan class=\"pl-s1\"\u003ec\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eread\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eremote\u003c/span\u003e() \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ec\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ecounters\u003c/span\u003e]\n\u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eget\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003efutures\u003c/span\u003e))\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eRay programs can run on a single machine, and can also seamlessly scale to large clusters. To execute the above Ray script in the cloud, just download \u003ca href=\"https://github.com/ray-project/ray/blob/master/python/ray/autoscaler/aws/example-full.yaml\"\u003ethis configuration file\u003c/a\u003e, and run:\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ccode\u003eray submit [CLUSTER.YAML] example.py --start\u003c/code\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003eRead more about \u003ca href=\"https://docs.ray.io/en/master/cluster/index.html\" rel=\"nofollow\"\u003elaunching clusters\u003c/a\u003e.\u003c/p\u003e\n\u003ca name=\"user-content-tune-quick-start\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eTune Quick Start\u003c/h2\u003e\u003ca id=\"user-content-tune-quick-start\" class=\"anchor\" aria-label=\"Permalink: Tune Quick Start\" href=\"#tune-quick-start\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/ray-project/ray/raw/master/doc/source/images/tune-wide.png\"\u003e\u003cimg alt=\"https://github.com/ray-project/ray/raw/master/doc/source/images/tune-wide.png\" src=\"https://github.com/ray-project/ray/raw/master/doc/source/images/tune-wide.png\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://docs.ray.io/en/master/tune.html\" rel=\"nofollow\"\u003eTune\u003c/a\u003e is a library for hyperparameter tuning at any scale.\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eLaunch a multi-node distributed hyperparameter sweep in less than 10 lines of code.\u003c/li\u003e\n\u003cli\u003eSupports any deep learning framework, including PyTorch, \u003ca href=\"https://github.com/williamFalcon/pytorch-lightning\"\u003ePyTorch Lightning\u003c/a\u003e, TensorFlow, and Keras.\u003c/li\u003e\n\u003cli\u003eVisualize results with \u003ca href=\"https://www.tensorflow.org/get_started/summaries_and_tensorboard\" rel=\"nofollow\"\u003eTensorBoard\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003eChoose among scalable SOTA algorithms such as \u003ca href=\"https://docs.ray.io/en/master/tune-schedulers.html#population-based-training-pbt\" rel=\"nofollow\"\u003ePopulation Based Training (PBT)\u003c/a\u003e, \u003ca href=\"https://docs.ray.io/en/master/tune-schedulers.html#median-stopping-rule\" rel=\"nofollow\"\u003eVizier's Median Stopping Rule\u003c/a\u003e, \u003ca href=\"https://docs.ray.io/en/master/tune-schedulers.html#asynchronous-hyperband\" rel=\"nofollow\"\u003eHyperBand/ASHA\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003eTune integrates with many optimization libraries such as \u003ca href=\"http://ax.dev\" rel=\"nofollow\"\u003eFacebook Ax\u003c/a\u003e, \u003ca href=\"https://github.com/hyperopt/hyperopt\"\u003eHyperOpt\u003c/a\u003e, and \u003ca href=\"https://github.com/fmfn/BayesianOptimization\"\u003eBayesian Optimization\u003c/a\u003e and enables you to scale them transparently.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eTo run this example, you will need to install the following:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"$ pip install \u0026quot;ray[tune]\u0026quot;\"\u003e\u003cpre\u003e$ pip install \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003eray[tune]\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis example runs a parallel grid search to optimize an example objective function.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"from ray import tune\n\n\ndef objective(step, alpha, beta):\n return (0.1 + alpha * step / 100)**(-1) + beta * 0.1\n\n\ndef training_function(config):\n # Hyperparameters\n alpha, beta = config[\u0026quot;alpha\u0026quot;], config[\u0026quot;beta\u0026quot;]\n for step in range(10):\n # Iterative training function - can be any arbitrary training procedure.\n intermediate_score = objective(step, alpha, beta)\n # Feed the score back back to Tune.\n tune.report(mean_loss=intermediate_score)\n\n\nanalysis = tune.run(\n training_function,\n config={\n \u0026quot;alpha\u0026quot;: tune.grid_search([0.001, 0.01, 0.1]),\n \u0026quot;beta\u0026quot;: tune.choice([1, 2, 3])\n })\n\nprint(\u0026quot;Best config: \u0026quot;, analysis.get_best_config(metric=\u0026quot;mean_loss\u0026quot;))\n\n# Get a dataframe for analyzing trial results.\ndf = analysis.results_df\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e\n\n\n\u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eobjective\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003estep\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ealpha\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebeta\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e (\u003cspan class=\"pl-c1\"\u003e0.1\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e+\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ealpha\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003estep\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e/\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e100\u003c/span\u003e)\u003cspan class=\"pl-c1\"\u003e**\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e-\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e) \u003cspan class=\"pl-c1\"\u003e+\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003ebeta\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e*\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0.1\u003c/span\u003e\n\n\n\u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003etraining_function\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e):\n \u003cspan class=\"pl-c\"\u003e# Hyperparameters\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003ealpha\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebeta\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"alpha\"\u003c/span\u003e], \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"beta\"\u003c/span\u003e]\n \u003cspan class=\"pl-k\"\u003efor\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003estep\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003ein\u003c/span\u003e \u003cspan class=\"pl-en\"\u003erange\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e10\u003c/span\u003e):\n \u003cspan class=\"pl-c\"\u003e# Iterative training function - can be any arbitrary training procedure.\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003eintermediate_score\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eobjective\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003estep\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ealpha\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebeta\u003c/span\u003e)\n \u003cspan class=\"pl-c\"\u003e# Feed the score back back to Tune.\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ereport\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003emean_loss\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003eintermediate_score\u003c/span\u003e)\n\n\n\u003cspan class=\"pl-s1\"\u003eanalysis\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003erun\u003c/span\u003e(\n \u003cspan class=\"pl-s1\"\u003etraining_function\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e{\n \u003cspan class=\"pl-s\"\u003e\"alpha\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003egrid_search\u003c/span\u003e([\u003cspan class=\"pl-c1\"\u003e0.001\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e0.01\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e0.1\u003c/span\u003e]),\n \u003cspan class=\"pl-s\"\u003e\"beta\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003echoice\u003c/span\u003e([\u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e2\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e3\u003c/span\u003e])\n })\n\n\u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"Best config: \"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eanalysis\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eget_best_config\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003emetric\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s\"\u003e\"mean_loss\"\u003c/span\u003e))\n\n\u003cspan class=\"pl-c\"\u003e# Get a dataframe for analyzing trial results.\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003edf\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eanalysis\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eresults_df\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eIf TensorBoard is installed, automatically visualize all trial results:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"tensorboard --logdir ~/ray_results\"\u003e\u003cpre\u003etensorboard --logdir \u003cspan class=\"pl-k\"\u003e~\u003c/span\u003e/ray_results\u003c/pre\u003e\u003c/div\u003e\n\u003ca name=\"user-content-rllib-quick-start\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRLlib Quick Start\u003c/h2\u003e\u003ca id=\"user-content-rllib-quick-start\" class=\"anchor\" aria-label=\"Permalink: RLlib Quick Start\" href=\"#rllib-quick-start\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/ray-project/ray/raw/master/doc/source/images/rllib-wide.jpg\"\u003e\u003cimg alt=\"https://github.com/ray-project/ray/raw/master/doc/source/images/rllib-wide.jpg\" src=\"https://github.com/ray-project/ray/raw/master/doc/source/images/rllib-wide.jpg\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://docs.ray.io/en/master/rllib.html\" rel=\"nofollow\"\u003eRLlib\u003c/a\u003e is an open-source library for reinforcement learning built on top of Ray that offers both high scalability and a unified API for a variety of applications.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"pip install tensorflow # or tensorflow-gpu\npip install \u0026quot;ray[rllib]\u0026quot;\"\u003e\u003cpre\u003epip install tensorflow \u003cspan class=\"pl-c\"\u003e\u003cspan class=\"pl-c\"\u003e#\u003c/span\u003e or tensorflow-gpu\u003c/span\u003e\npip install \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003eray[rllib]\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"import gym\nfrom gym.spaces import Discrete, Box\nfrom ray import tune\n\nclass SimpleCorridor(gym.Env):\n def __init__(self, config):\n self.end_pos = config[\u0026quot;corridor_length\u0026quot;]\n self.cur_pos = 0\n self.action_space = Discrete(2)\n self.observation_space = Box(0.0, self.end_pos, shape=(1, ))\n\n def reset(self):\n self.cur_pos = 0\n return [self.cur_pos]\n\n def step(self, action):\n if action == 0 and self.cur_pos \u0026gt; 0:\n self.cur_pos -= 1\n elif action == 1:\n self.cur_pos += 1\n done = self.cur_pos \u0026gt;= self.end_pos\n return [self.cur_pos], 1 if done else 0, done, {}\n\ntune.run(\n \u0026quot;PPO\u0026quot;,\n config={\n \u0026quot;env\u0026quot;: SimpleCorridor,\n \u0026quot;num_workers\u0026quot;: 4,\n \u0026quot;env_config\u0026quot;: {\u0026quot;corridor_length\u0026quot;: 5}})\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003egym\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003egym\u003c/span\u003e.\u003cspan class=\"pl-s1\"\u003espaces\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eDiscrete\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eBox\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e\n\n\u003cspan class=\"pl-k\"\u003eclass\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eSimpleCorridor\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003egym\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eEnv\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__init__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eend_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"corridor_length\"\u003c/span\u003e]\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eaction_space\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eDiscrete\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e2\u003c/span\u003e)\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eobservation_space\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eBox\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e0.0\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eend_pos\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eshape\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e(\u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e, ))\n\n 8000 \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003ereset\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e [\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e]\n\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003estep\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eaction\u003c/span\u003e):\n \u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eaction\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e==\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003eand\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026gt;\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e:\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e-=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e\n \u003cspan class=\"pl-k\"\u003eelif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eaction\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e==\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e:\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e+=\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003edone\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e\u0026gt;=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eend_pos\u003c/span\u003e\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e [\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecur_pos\u003c/span\u003e], \u003cspan class=\"pl-c1\"\u003e1\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eif\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003edone\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eelse\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003edone\u003c/span\u003e, {}\n\n\u003cspan class=\"pl-s1\"\u003etune\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003erun\u003c/span\u003e(\n \u003cspan class=\"pl-s\"\u003e\"PPO\"\u003c/span\u003e,\n \u003cspan class=\"pl-s1\"\u003econfig\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e{\n \u003cspan class=\"pl-s\"\u003e\"env\"\u003c/span\u003e: \u003cspan class=\"pl-v\"\u003eSimpleCorridor\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"num_workers\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e4\u003c/span\u003e,\n \u003cspan class=\"pl-s\"\u003e\"env_config\"\u003c/span\u003e: {\u003cspan class=\"pl-s\"\u003e\"corridor_length\"\u003c/span\u003e: \u003cspan class=\"pl-c1\"\u003e5\u003c/span\u003e}})\u003c/pre\u003e\u003c/div\u003e\n\u003ca name=\"user-content-ray-serve-quick-start\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eRay Serve Quick Start\u003c/h2\u003e\u003ca id=\"user-content-ray-serve-quick-start\" class=\"anchor\" aria-label=\"Permalink: Ray Serve Quick Start\" href=\"#ray-serve-quick-start\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003e\u003ca target=\"_blank\" rel=\"noopener noreferrer nofollow\" href=\"https://raw.githubusercontent.com/ray-project/ray/master/doc/source/serve/logo.svg\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/ray-project/ray/master/doc/source/serve/logo.svg\" width=\"400\" style=\"max-width: 100%;\"\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp dir=\"auto\"\u003e\u003ca href=\"https://docs.ray.io/en/master/serve/index.html\" rel=\"nofollow\"\u003eRay Serve\u003c/a\u003e is a scalable model-serving library built on Ray. It is:\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003eFramework Agnostic: Use the same toolkit to serve everything from deep\nlearning models built with frameworks like PyTorch or Tensorflow \u0026amp; Keras\nto Scikit-Learn models or arbitrary business logic.\u003c/li\u003e\n\u003cli\u003ePython First: Configure your model serving with pure Python code - no more\nYAMLs or JSON configs.\u003c/li\u003e\n\u003cli\u003ePerformance Oriented: Turn on batching, pipelining, and GPU acceleration to\nincrease the throughput of your model.\u003c/li\u003e\n\u003cli\u003eComposition Native: Allow you to create \"model pipelines\" by composing multiple\nmodels together to drive a single prediction.\u003c/li\u003e\n\u003cli\u003eHorizontally Scalable: Serve can linearly scale as you add more machines. Enable\nyour ML-powered service to handle growing traffic.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003eTo run this example, you will need to install the following:\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"$ pip install scikit-learn\n$ pip install \u0026quot;ray[serve]\u0026quot;\"\u003e\u003cpre\u003e$ pip install scikit-learn\n$ pip install \u003cspan class=\"pl-s\"\u003e\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003eray[serve]\u003cspan class=\"pl-pds\"\u003e\"\u003c/span\u003e\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003cp dir=\"auto\"\u003eThis example runs serves a scikit-learn gradient boosting classifier.\u003c/p\u003e\n\u003cdiv class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"from ray import serve\nimport pickle\nimport requests\nfrom sklearn.datasets import load_iris\nfrom sklearn.ensemble import GradientBoostingClassifier\n\n# Train model\niris_dataset = load_iris()\nmodel = GradientBoostingClassifier()\nmodel.fit(iris_dataset[\u0026quot;data\u0026quot;], iris_dataset[\u0026quot;target\u0026quot;])\n\n# Define Ray Serve model,\nclass BoostingModel:\n def __init__(self):\n self.model = model\n self.label_list = iris_dataset[\u0026quot;target_names\u0026quot;].tolist()\n\n def __call__(self, flask_request):\n payload = flask_request.json[\u0026quot;vector\u0026quot;]\n print(\u0026quot;Worker: received flask request with data\u0026quot;, payload)\n\n prediction = self.model.predict([payload])[0]\n human_name = self.label_list[prediction]\n return {\u0026quot;result\u0026quot;: human_name}\n\n\n# Deploy model\nclient = serve.start()\nclient.create_backend(\u0026quot;iris:v1\u0026quot;, BoostingModel)\nclient.create_endpoint(\u0026quot;iris_classifier\u0026quot;, backend=\u0026quot;iris:v1\u0026quot;, route=\u0026quot;/iris\u0026quot;)\n\n# Query it!\nsample_request_input = {\u0026quot;vector\u0026quot;: [1.2, 1.0, 1.1, 0.9]}\nresponse = requests.get(\u0026quot;http://localhost:8000/iris\u0026quot;, json=sample_request_input)\nprint(response.text)\n# Result:\n# {\n# \u0026quot;result\u0026quot;: \u0026quot;versicolor\u0026quot;\n# }\"\u003e\u003cpre\u003e\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eray\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eserve\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003epickle\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erequests\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esklearn\u003c/span\u003e.\u003cspan class=\"pl-s1\"\u003edatasets\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eload_iris\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003efrom\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003esklearn\u003c/span\u003e.\u003cspan class=\"pl-s1\"\u003eensemble\u003c/span\u003e \u003cspan class=\"pl-k\"\u003eimport\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eGradientBoostingClassifier\u003c/span\u003e\n\n\u003cspan class=\"pl-c\"\u003e# Train model\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003eiris_dataset\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eload_iris\u003c/span\u003e()\n\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-en\"\u003eGradientBoostingClassifier\u003c/span\u003e()\n\u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003efit\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eiris_dataset\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"data\"\u003c/span\u003e], \u003cspan class=\"pl-s1\"\u003eiris_dataset\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"target\"\u003c/span\u003e])\n\n\u003cspan class=\"pl-c\"\u003e# Define Ray Serve model,\u003c/span\u003e\n\u003cspan class=\"pl-k\"\u003eclass\u003c/span\u003e \u003cspan class=\"pl-v\"\u003eBoostingModel\u003c/span\u003e:\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__init__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003emodel\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003emodel\u003c/span\u003e\n \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003elabel_list\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eiris_dataset\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"target_names\"\u003c/span\u003e].\u003cspan class=\"pl-c1\"\u003etolist\u003c/span\u003e()\n\n \u003cspan class=\"pl-k\"\u003edef\u003c/span\u003e \u003cspan class=\"pl-en\"\u003e__call__\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eflask_request\u003c/span\u003e):\n \u003cspan class=\"pl-s1\"\u003epayload\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eflask_request\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ejson\u003c/span\u003e[\u003cspan class=\"pl-s\"\u003e\"vector\"\u003c/span\u003e]\n \u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"Worker: received flask request with data\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003epayload\u003c/span\u003e)\n\n \u003cspan class=\"pl-s1\"\u003eprediction\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003emodel\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003epredict\u003c/span\u003e([\u003cspan class=\"pl-s1\"\u003epayload\u003c/span\u003e])[\u003cspan class=\"pl-c1\"\u003e0\u003c/span\u003e]\n \u003cspan class=\"pl-s1\"\u003ehuman_name\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eself\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003elabel_list\u003c/span\u003e[\u003cspan class=\"pl-s1\"\u003eprediction\u003c/span\u003e]\n \u003cspan class=\"pl-k\"\u003ereturn\u003c/span\u003e {\u003cspan class=\"pl-s\"\u003e\"result\"\u003c/span\u003e: \u003cspan class=\"pl-s1\"\u003ehuman_name\u003c/span\u003e}\n\n\n\u003cspan class=\"pl-c\"\u003e# Deploy model\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003eserve\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003estart\u003c/span\u003e()\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecreate_backend\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"iris:v1\"\u003c/span\u003e, \u003cspan class=\"pl-v\"\u003eBoostingModel\u003c/span\u003e)\n\u003cspan class=\"pl-s1\"\u003eclient\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003ecreate_endpoint\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"iris_classifier\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ebackend\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s\"\u003e\"iris:v1\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003eroute\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s\"\u003e\"/iris\"\u003c/span\u003e)\n\n\u003cspan class=\"pl-c\"\u003e# Query it!\u003c/span\u003e\n\u003cspan class=\"pl-s1\"\u003esample_request_input\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e {\u003cspan class=\"pl-s\"\u003e\"vector\"\u003c/span\u003e: [\u003cspan class=\"pl-c1\"\u003e1.2\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e1.0\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e1.1\u003c/span\u003e, \u003cspan class=\"pl-c1\"\u003e0.9\u003c/span\u003e]}\n\u003cspan class=\"pl-s1\"\u003eresponse\u003c/span\u003e \u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e \u003cspan class=\"pl-s1\"\u003erequests\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003eget\u003c/span\u003e(\u003cspan class=\"pl-s\"\u003e\"http://localhost:8000/iris\"\u003c/span\u003e, \u003cspan class=\"pl-s1\"\u003ejson\u003c/span\u003e\u003cspan class=\"pl-c1\"\u003e=\u003c/span\u003e\u003cspan class=\"pl-s1\"\u003esample_request_input\u003c/span\u003e)\n\u003cspan class=\"pl-en\"\u003eprint\u003c/span\u003e(\u003cspan class=\"pl-s1\"\u003eresponse\u003c/span\u003e.\u003cspan class=\"pl-c1\"\u003etext\u003c/span\u003e)\n\u003cspan class=\"pl-c\"\u003e# Result:\u003c/span\u003e\n\u003cspan class=\"pl-c\"\u003e# {\u003c/span\u003e\n\u003cspan class=\"pl-c\"\u003e# \"result\": \"versicolor\"\u003c/span\u003e\n\u003cspan class=\"pl-c\"\u003e# }\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\n\u003ca name=\"user-content-more-information\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eMore Information\u003c/h2\u003e\u003ca id=\"user-content-more-information\" class=\"anchor\" aria-label=\"Permalink: More Information\" href=\"#more-information\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"http://docs.ray.io/en/master/index.html\" rel=\"nofollow\"\u003eDocumentation\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/ray-project/tutorial\"\u003eTutorial\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://medium.com/distributed-computing-with-ray\" rel=\"nofollow\"\u003eBlog\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://docs.google.com/document/d/1lAy0Owi-vPz2jEqBSaHNQcy2IBSDEHyXNOQZlGuj93c/preview\" rel=\"nofollow\"\u003eRay 1.0 Architecture whitepaper\u003c/a\u003e \u003cstrong\u003e(new)\u003c/strong\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://docs.google.com/document/d/167rnnDFIVRhHhK4mznEIemOtj63IOhtIPvSYaPgI4Fg/edit\" rel=\"nofollow\"\u003eRay Design Patterns\u003c/a\u003e \u003cstrong\u003e(new)\u003c/strong\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://arxiv.org/abs/1712.09381\" rel=\"nofollow\"\u003eRLlib paper\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://arxiv.org/abs/1807.05118\" rel=\"nofollow\"\u003eTune paper\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp dir=\"auto\"\u003e\u003cem\u003eOlder documents:\u003c/em\u003e\u003c/p\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://arxiv.org/abs/1712.05889\" rel=\"nofollow\"\u003eRay paper\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://arxiv.org/abs/1703.03924\" rel=\"nofollow\"\u003eRay HotOS paper\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://ray-project.github.io/\" rel=\"nofollow\"\u003eBlog (old)\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003ca name=\"user-content-getting-involved\"\u003e\u003c/a\u003e\n\u003cdiv class=\"markdown-heading\" dir=\"auto\"\u003e\u003ch2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\"\u003eGetting Involved\u003c/h2\u003e\u003ca id=\"user-content-getting-involved\" class=\"anchor\" aria-label=\"Permalink: Getting Involved\" href=\"#getting-involved\"\u003e\u003csvg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"\u003e\u003cpath d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"\u003e\u003c/path\u003e\u003c/svg\u003e\u003c/a\u003e\u003c/div\u003e\n\u003cul dir=\"auto\"\u003e\n\u003cli\u003e\u003ca href=\"https://forms.gle/9TSdDYUgxYs8SA9e8\" rel=\"nofollow\"\u003eCommunity Slack\u003c/a\u003e: Join our Slack workspace.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://discuss.ray.io/\" rel=\"nofollow\"\u003eForum\u003c/a\u003e: For discussions about development, questions about usage, and feature requests.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/ray-project/ray/issues\"\u003eGitHub Issues\u003c/a\u003e: For reporting bugs.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://twitter.com/raydistributed\" rel=\"nofollow\"\u003eTwitter\u003c/a\u003e: Follow updates on Twitter.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.meetup.com/Bay-Area-Ray-Meetup/\" rel=\"nofollow\"\u003eMeetup Group\u003c/a\u003e: Join our meetup group.\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://stackoverflow.com/questions/tagged/ray\" rel=\"nofollow\"\u003eStackOverflow\u003c/a\u003e: For questions about how to use Ray.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003c/article\u003e","loaded":true,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":[{"level":2,"text":"Quick Start","anchor":"quick-start","htmlText":"Quick Start"},{"level":2,"text":"Tune Quick Start","anchor":"tune-quick-start","htmlText":"Tune Quick Start"},{"level":2,"text":"RLlib Quick Start","anchor":"rllib-quick-start","htmlText":"RLlib Quick Start"},{"level":2,"text":"Ray Serve Quick Start","anchor":"ray-serve-quick-start","htmlText":"Ray Serve Quick Start"},{"level":2,"text":"More Information","anchor":"more-information","htmlText":"More Information"},{"level":2,"text":"Getting Involved","anchor":"getting-involved","htmlText":"Getting Involved"}],"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fmariodoebler%2Fray"}},{"displayName":"LICENSE","repoName":"ray","refName":"master","path":"LICENSE","preferredFileType":"license","tabName":"Apache-2.0","richText":null,"loaded":false,"timedOut":false,"errorMessage":null,"headerInfo":{"toc":null,"siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fmariodoebler%2Fray"}}],"overviewFilesProcessingTime":0}},"appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-708ec8ade250.js","githubDevUrl":null,"enabled_features":{"copilot_workspace":null,"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}}
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://github.com/ray-project/ray/raw/master/doc/source/images/ray_header_logo.png

https://readthedocs.org/projects/ray/badge/?version=master https://img.shields.io/badge/Ray-Join%20Slack-blue https://img.shields.io/badge/Discuss-Ask%20Questions-blue

Ray provides a simple, universal API for building distributed applications.

Ray is packaged with the following libraries for accelerating machine learning workloads:

  • Tune: Scalable Hyperparameter Tuning
  • RLlib: Scalable Reinforcement Learning
  • RaySGD: Distributed Training Wrappers
  • Ray Serve: Scalable and Programmable Serving

There are also many community integrations with Ray, including Dask, MARS, Modin, Horovod, Hugging Face, Scikit-learn, and others. Check out the full list of Ray distributed libraries here.

Install Ray with: pip install ray. For nightly wheels, see the Installation page.

Quick Start

Execute Python functions in parallel.

import ray
ray.init()

@ray.remote
def f(x):
    return x * x

futures = [f.remote(i) for i in range(4)]
print(ray.get(futures))

To use Ray's actor model:

import ray
ray.init()

@ray.remote
class Counter(object):
    def __init__(self):
        self.n = 0

    def increment(self):
        self.n += 1

    def read(self):
        return self.n

counters = [Counter.remote() for i in range(4)]
[c.increment.remote() for c in counters]
futures = [c.read.remote() for c in counters]
print(ray.get(futures))

Ray programs can run on a single machine, and can also seamlessly scale to large clusters. To execute the above Ray script in the cloud, just download this configuration file, and run:

ray submit [CLUSTER.YAML] example.py --start

Read more about launching clusters.

Tune Quick Start

https://github.com/ray-project/ray/raw/master/doc/source/images/tune-wide.png

Tune is a library for hyperparameter tuning at any scale.

To run this example, you will need to install the following:

$ pip install "ray[tune]"

This example runs a parallel grid search to optimize an example objective function.

from ray import tune


def objective(step, alpha, beta):
    return (0.1 + alpha * step / 100)**(-1) + beta * 0.1


def
8000
 training_function(config):
    # Hyperparameters
    alpha, beta = config["alpha"], config["beta"]
    for step in range(10):
        # Iterative training function - can be any arbitrary training procedure.
        intermediate_score = objective(step, alpha, beta)
        # Feed the score back back to Tune.
        tune.report(mean_loss=intermediate_score)


analysis = tune.run(
    training_function,
    config={
        "alpha": tune.grid_search([0.001, 0.01, 0.1]),
        "beta": tune.choice([1, 2, 3])
    })

print("Best config: ", analysis.get_best_config(metric="mean_loss"))

# Get a dataframe for analyzing trial results.
df = analysis.results_df

If TensorBoard is installed, automatically visualize all trial results:

tensorboard --logdir ~/ray_results

RLlib Quick Start

https://github.com/ray-project/ray/raw/master/doc/source/images/rllib-wide.jpg

RLlib is an open-source library for reinforcement learning built on top of Ray that offers both high scalability and a unified API for a variety of applications.

pip install tensorflow  # or tensorflow-gpu
pip install "ray[rllib]"
import gym
from gym.spaces import Discrete, Box
from ray import tune

class SimpleCorridor(gym.Env):
    def __init__(self, config):
        self.end_pos = config["corridor_length"]
        self.cur_pos = 0
        self.action_space = Discrete(2)
        self.observation_space = Box(0.0, self.end_pos, shape=(1, ))

    def reset(self):
        self.cur_pos = 0
        return [self.cur_pos]

    def step(self, action):
        if action == 0 and self.cur_pos > 0:
            self.cur_pos -= 1
        elif action == 1:
            self.cur_pos += 1
        done = self.cur_pos >= self.end_pos
        return [self.cur_pos], 1 if done else 0, done, {}

tune.run(
    "PPO",
    config={
        "env": SimpleCorridor,
        "num_workers": 4,
        "env_config": {"corridor_length": 5}})

Ray Serve Quick Start

Ray Serve is a scalable model-serving library built on Ray. It is:

  • Framework Agnostic: Use the same toolkit to serve everything from deep learning models built with frameworks like PyTorch or Tensorflow & Keras to Scikit-Learn models or arbitrary business logic.
  • Python First: Configure your model serving with pure Python code - no more YAMLs or JSON configs.
  • Performance Oriented: Turn on batching, pipelining, and GPU acceleration to increase the throughput of your model.
  • Composition Native: Allow you to create "model pipelines" by composing multiple models together to drive a single prediction.
  • Horizontally Scalable: Serve can linearly scale as you add more machines. Enable your ML-powered service to handle growing traffic.

To run this example, you will need to install the following:

$ pip install scikit-learn
$ pip install "ray[serve]"

This example runs serves a scikit-learn gradient boosting classifier.

from ray import serve
import pickle
import requests
from sklearn.datasets import load_iris
from sklearn.ensemble import GradientBoostingClassifier

# Train model
iris_dataset = load_iris()
model = GradientBoostingClassifier()
model.fit(iris_dataset["data"], iris_dataset["target"])

# Define Ray Serve model,
class BoostingModel:
    def __init__(self):
        self.model = model
        self.label_list = iris_dataset["target_names"].tolist()

    def __call__(self, flask_request):
        payload = flask_request.json["vector"]
        print("Worker: received flask request with data", payload)

        prediction = self.model.predict([payload])[0]
        human_name = self.label_list[prediction]
        return {"result": human_name}


# Deploy model
client = serve.start()
client.create_backend("iris:v1", BoostingModel)
client.create_endpoint("iris_classifier", backend="iris:v1", route="/iris")

# Query it!
sample_request_input = {"vector": [1.2, 1.0, 1.1, 0.9]}
response = requests.get("http://localhost:8000/iris", json=sample_request_input)
print(response.text)
# Result:
# {
#  "result": "versicolor"
# }

More Information

Older documents:

Getting Involved

About

An open source framework that provides a simple, universal API for building distributed applications. Ray is packaged with RLlib, a scalable reinforcement learning library, and Tune, a scalable hyperparameter tuning library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 55.6%
  • C++ 31.2%
  • Java 9.0%
  • Starlark 1.5%
  • TypeScript 1.1%
  • Shell 0.8%
  • Other 0.8%
0