-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Ray on spark #1449
Merged
Merged
Enhance Ray on spark #1449
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ You need to first [install](install.md) analytics-zoo, either [from pip](install | |
**NOTE**: Only __Python 2.7__, __Python 3.5__ and __Python 3.6__ are supported for now. | ||
|
||
--- | ||
|
||
## **Run after pip install** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rum on local node after pip install |
||
|
||
**Important:** | ||
|
@@ -48,6 +49,28 @@ export BIGDL_JARS=... | |
export BIGDL_PACKAGES=... | ||
``` | ||
|
||
## **Run on yarn after pip install | ||
|
||
Start python and then execute the following code: | ||
Caveat: You should use `init_spark_on_yarn` rather than `init_nncontext()` here. | ||
- Create a SparkContext on Yarn | ||
|
||
``` python | ||
|
||
from zoo import init_spark_on_yarn | ||
|
||
sc = init_spark_on_yarn( | ||
hadoop_conf="path to the yarn configuration folder", | ||
conda_name="zoo", # The name of the created conda-env | ||
num_executor=2, | ||
executor_cores=4, | ||
executor_memory="8g", | ||
driver_memory="2g", | ||
driver_cores=4, | ||
extra_executor_memory_for_ray="10g") | ||
|
||
``` | ||
|
||
--- | ||
## **Run without pip install** | ||
- Note that __Python 3.6__ is only compatible with Spark 1.6.4, 2.0.3, 2.1.1 and >=2.2.0. See [this issue](https://issues.apache.org/jira/browse/SPARK-19019) for more discussion. | ||
|
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
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 |
---|---|---|
|
@@ -92,7 +92,8 @@ def _prepare_env(self, cores=None): | |
return modified_env | ||
|
||
def __init__(self, python_loc, redis_port, ray_node_cpu_cores, mkl_cores, | ||
password, object_store_memory, waitting_time_sec=6, verbose=False, env=None): | ||
password, object_store_memory, waitting_time_sec=6, verbose=False, env=None, | ||
extra_params=None): | ||
"""object_store_memory: integer in bytes""" | ||
self.env = env | ||
self.python_loc = python_loc | ||
|
@@ -103,6 +104,7 @@ def __init__(self, python_loc, redis_port, ray_node_cpu_cores, mkl_cores, | |
self.ray_exec = self._get_ray_exec() | ||
self.object_store_memory = object_store_memory | ||
self.waiting_time_sec = waitting_time_sec | ||
self.extra_params = extra_params | ||
self.verbose = verbose | ||
self.labels = """--resources='{"trainer": %s, "ps": %s }' """ % (1, 1) | ||
|
||
|
@@ -115,22 +117,25 @@ def _stop(iter): | |
|
||
return _stop | ||
|
||
def _gen_master_command(self): | ||
command = "{} start --head " \ | ||
"--include-webui --redis-port {} \ | ||
--redis-password {} --num-cpus {} ". \ | ||
format(self.ray_exec, self.redis_port, self.password, self.ray_node_cpu_cores) | ||
def _enrich_command(self, command): | ||
if self.object_store_memory: | ||
command = command + "--object-store-memory {} ".format(str(self.object_store_memory)) | ||
if self.extra_params: | ||
for pair in self.extra_params.items(): | ||
command = command + " --{} {} ".format(pair[0], pair[1]) | ||
return command | ||
|
||
def _gen_master_command(self): | ||
command = "{} start --head " \ | ||
"--include-webui --redis-port {} " \ | ||
"--redis-password {} --num-cpus {} ". \ | ||
format(self.ray_exec, self.redis_port, self.password, self.ray_node_cpu_cores) | ||
return self._enrich_command(command) | ||
|
||
def _get_raylet_command(self, redis_address): | ||
command = "{} start --redis-address {} --redis-password {} --num-cpus {} {} ".format( | ||
self.ray_exec, redis_address, self.password, self.ray_node_cpu_cores, self.labels) | ||
|
||
if self.object_store_memory: | ||
command = command + "--object-store-memory {} ".format(str(self.object_store_memory)) | ||
return command | ||
return self._enrich_command(command) | ||
|
||
def _start_ray_node(self, command, tag, wait_before=5, wait_after=5): | ||
modified_env = self._prepare_env(self.mkl_cores) | ||
|
@@ -180,18 +185,24 @@ def _start_ray_services(iter): | |
|
||
class RayContext(object): | ||
def __init__(self, sc, redis_port=None, password="123456", object_store_memory=None, | ||
verbose=False, env=None, local_ray_node_num=2, waitting_time_sec=8): | ||
verbose=False, env=None, local_ray_node_num=2, waiting_time_sec=8, | ||
extra_params=None): | ||
""" | ||
The RayContext would init a ray cluster on top of the configuration of the SparkContext. | ||
The RayContext would init a ray cluster on top of the configuration of SparkContext. | ||
For spark cluster mode: The number of raylets is equal to number of executors. | ||
For Spark local mode: The number of raylets is controlled by local_ray_node_num. | ||
CPU cores for each raylet equals to spark_cores/local_ray_node_num. | ||
CPU cores for each is raylet equals to spark_cores/local_ray_node_num. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is? |
||
:param sc: | ||
:param redis_port: redis port for the "head" node. | ||
The value would be randomly picked if not specified | ||
:param local_ray_node_num number of raylets to be created. | ||
The value would be randomly picked if not specified. | ||
:param password: [optional] password for the redis. | ||
:param object_store_memory: Memory size for the object_store. | ||
:param verbose: True for more logs. | ||
:param env: The environment variable dict for running Ray. | ||
:param local_ray_node_num number of raylets to be created. | ||
:param waiting_time_sec: Waiting time for the raylets before connecting to redis. | ||
:param extra_params: key value dictionary for extra options to launch Ray. | ||
i.e extra_params={"temp-dir": "/tmp/ray2/"} | ||
""" | ||
self.sc = sc | ||
self.stopped = False | ||
|
@@ -212,7 +223,8 @@ def __init__(self, sc, redis_port=None, password="123456", object_store_memory=N | |
object_store_memory=self._enrich_object_sotre_memory(sc, object_store_memory), | ||
verbose=verbose, | ||
env=env, | ||
waitting_time_sec=waitting_time_sec) | ||
waitting_time_sec=waiting_time_sec, | ||
extra_params=extra_params) | ||
self._gather_cluster_ips() | ||
from bigdl.util.common import init_executor_gateway | ||
print("Start to launch the JVM guarding process") | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting this empty line will break the layout on website. Recovered it in #1512