Skip to content
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

[PPML] Fix tracker bind issue happens in xgboost examples with SGX enabled #5766

Merged
merged 6 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/readthedocs/source/doc/PPML/Overview/ppml.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ The result should look something like this:

This example shows how to run trusted Spark XGBoost Regressor.

First, make sure that `Boston_Housing.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-regressor-sgx.sh`. Replace the value of `RABIT_TRACKER_IP` with your own IP address in the script.
First, make sure that `Boston_Housing.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-regressor-sgx.sh`.

Run the script to run trusted Spark XGBoost Regressor and it would take some time to show the final results:

Expand Down Expand Up @@ -643,7 +643,7 @@ The result should look something like this:

This example shows how to run trusted Spark XGBoost Classifier.

Before running the example, download the sample dataset from [pima-indians-diabetes](https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv) dataset. After downloading the dataset, make sure that `pima-indians-diabetes.data.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-classifier-sgx.sh`. Replace `path_of_pima_indians_diabetes_csv` with your path of `pima-indians-diabetes.data.csv` and the value of `RABIT_TRACKER_IP` with your own IP address in the script.
Before running the example, download the sample dataset from [pima-indians-diabetes](https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv) dataset. After downloading the dataset, make sure that `pima-indians-diabetes.data.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-classifier-sgx.sh`. Replace `path_of_pima_indians_diabetes_csv` with your path of `pima-indians-diabetes.data.csv`.

Run the script to run trusted Spark XGBoost Classifier and it would take some time to show the final results:

Expand Down
4 changes: 2 additions & 2 deletions ppml/docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ bash bigdl-ppml-submit.sh \
<details><summary>This example shows how to run trusted Spark XGBoost Regressor.</summary>


First, make sure that `Boston_Housing.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-regressor-sgx.sh`. Replace the value of `RABIT_TRACKER_IP` with your own IP address in the script.
First, make sure that `Boston_Housing.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-regressor-sgx.sh`.

Run the script to run trusted Spark XGBoost Regressor and it would take some time to show the final results:

Expand Down Expand Up @@ -368,7 +368,7 @@ The result should look something like this:
<details><summary>This example shows how to run trusted Spark XGBoost Classifier.</summary>


Before running the example, download the sample dataset from [pima-indians-diabetes](https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv) dataset. After downloading the dataset, make sure that `pima-indians-diabetes.data.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-classifier-sgx.sh`. Replace `path_of_pima_indians_diabetes_csv` with your path of `pima-indians-diabetes.data.csv` and the value of `RABIT_TRACKER_IP` with your own IP address in the script.
Before running the example, download the sample dataset from [pima-indians-diabetes](https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv) dataset. After downloading the dataset, make sure that `pima-indians-diabetes.data.csv` is under `work/data` directory or the same path in the `start-spark-local-xgboost-classifier-sgx.sh`. Replace `path_of_pima_indians_diabetes_csv` with your path of `pima-indians-diabetes.data.csv`.

Run the script to run trusted Spark XGBoost Classifier and it would take some time to show the final results:

Expand Down
10 changes: 5 additions & 5 deletions ppml/trusted-big-data-ml/python/docker-gramine/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,12 @@ def start_rabit_tracker(args):

def main():
"""Main function if tracker is executed in standalone mode."""
host_ip = os.environ['RABIT_TRACKER_IP']
if host_ip == None:
sys.stdout.write("###PYTHONWARN### RABIT_TRACKER_IP not set in env")

parser = argparse.ArgumentParser(description='Rabit Tracker start.')
parser.add_argument('--num-workers', required=True, type=int,
help='Number of worker proccess to be launched.')
parser.add_argument('--num-servers', default=0, type=int,
help='Number of server process to be launched. Only used in PS jobs.')
parser.add_argument('--host-ip', default=host_ip, type=str,
parser.add_argument('--host-ip', default=None, type=str,
help=('Host IP addressed, this is only needed ' +
'if the host IP cannot be automatically guessed.'))
parser.add_argument('--log-level', default='INFO', type=str,
Expand All @@ -473,6 +469,10 @@ def main():
args = parser.parse_args()
sys.stdout.write("###PYTHONWARN### args for tracker: " + str(args))

# Open a file and prepare to set the hostname
with open("/etc/hostname", 'r') as f:
hostname = f.readline().strip()
socket.sethostname(hostname)
fmt = '%(asctime)s %(levelname)s %(message)s'
if args.log_level == 'INFO':
level = logging.INFO
Expand Down
4 changes: 2 additions & 2 deletions ppml/trusted-big-data-ml/python/docker-graphene/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ After changing:
> 0.00632,18,2.31,**0**,0.538,6.575,65.2,4.09,1,296,15.3,396.9,4.98,24

```bash
/graphene/Tools/argv_serializer bash -c "export RABIT_TRACKER_IP=your_IP_address && /opt/jdk8/bin/java -cp \
/graphene/Tools/argv_serializer bash -c "/opt/jdk8/bin/java -cp \
'/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/jars/*:/ppml/trusted-big-data-ml/work/spark-3.1.2/conf/:/ppml/trusted-big-data-ml/work/spark-3.1.2/jars/*' \
-Xmx2g \
org.apache.spark.deploy.SparkSubmit \
Expand Down Expand Up @@ -514,7 +514,7 @@ wget https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-di
After downloading the dataset, make sure that `pima-indians-diabetes.data.csv` is under `work/data` directory or the same path in the command. Run the example with SGX spark local mode with the following command in the terminal. Replace `your_IP_address` with your IP address and `path_of_pima_indians_diabetes_csv` with your path of `pima-indians-diabetes.data.csv`.

```bash
/graphene/Tools/argv_serializer bash -c "export RABIT_TRACKER_IP=your_IP_address && /opt/jdk8/bin/java -cp \
/graphene/Tools/argv_serializer bash -c "/opt/jdk8/bin/java -cp \
'/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/jars/*:/ppml/trusted-big-data-ml/work/spark-3.1.2/conf/:/ppml/trusted-big-data-ml/work/spark-3.1.2/jars/*' \
-Xmx2g \
org.apache.spark.deploy.SparkSubmit \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
SGX=1 ./pal_loader bash -c "export RABIT_TRACKER_IP=your_IP_address && /opt/jdk8/bin/java -cp \
SGX=1 ./pal_loader bash -c "/opt/jdk8/bin/java -cp \
'/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/jars/*:/ppml/trusted-big-data-ml/work/spark-3.1.2/conf/:/ppml/trusted-big-data-ml/work/spark-3.1.2/jars/*' \
-Xmx2g \
org.apache.spark.deploy.SparkSubmit \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
SGX=1 ./pal_loader bash -c "export RABIT_TRACKER_IP=your_IP_address && /opt/jdk8/bin/java -cp \
SGX=1 ./pal_loader bash -c "/opt/jdk8/bin/java -cp \
'/ppml/trusted-big-data-ml/work/bigdl-2.1.0-SNAPSHOT/jars/*:/ppml/trusted-big-data-ml/work/spark-3.1.2/conf/:/ppml/trusted-big-data-ml/work/spark-3.1.2/jars/*' \
-Xmx2g \
org.apache.spark.deploy.SparkSubmit \
Expand Down
10 changes: 5 additions & 5 deletions ppml/trusted-big-data-ml/python/docker-graphene/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,12 @@ def start_rabit_tracker(args):

def main():
"""Main function if tracker is executed in standalone mode."""
host_ip = os.environ.get("RABIT_TRACKER_IP")
if host_ip == None:
sys.stdout.write("###PYTHONWARN### RABIT_TRACKER_IP not set in env")

parser = argparse.ArgumentParser(description='Rabit Tracker start.')
parser.add_argument('--num-workers', required=True, type=int,
help='Number of worker proccess to be launched.')
parser.add_argument('--num-servers', default=0, type=int,
help='Number of server process to be launched. Only used in PS jobs.')
parser.add_argument('--host-ip', default=host_ip, type=str,
parser.add_argument('--host-ip', default=None, type=str,
help=('Host IP addressed, this is only needed ' +
'if the host IP cannot be automatically guessed.'))
parser.add_argument('--log-level', default='INFO', type=str,
Expand All @@ -473,6 +469,10 @@ def main():
args = parser.parse_args()
sys.stdout.write("###PYTHONWARN### args for tracker: " + str(args))

# Open a file and prepare to set the hostname
with open("/etc/hostname", 'r') as f:
hostname = f.readline().strip()
socket.sethostname(hostname)
fmt = '%(asctime)s %(levelname)s %(message)s'
if args.log_level == 'INFO':
level = logging.INFO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

def process(filepath, demo):
sparkConf = init_spark_conf().setAppName("testXGBClassifier")
sparkConf = sparkConf.set("xgboost.spark.ignoreSsl", True)
sc = init_nncontext(sparkConf)
sqlContext = SQLContext(sc)
if demo:
Expand Down
3 changes: 2 additions & 1 deletion python/dllib/examples/nnframes/xgboost/xgboost_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@

def Processdata(filepath, demo):
'''
preProcess the data read from filepath
preProcess the data read from filepath
:param filepath:
:return: assembledf:
'''
sparkConf = init_spark_conf().setAppName("testNNClassifer")
sparkConf = sparkConf.set("xgboost.spark.ignoreSsl", True)
sc = init_nncontext(sparkConf)
sqlContext = SQLContext(sc)
if demo:
Expand Down
3 changes: 2 additions & 1 deletion python/dllib/examples/nnframes/xgboost/xgboost_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@

def Processdata(filepath, demo):
'''
preProcess the data read from filepath
preProcess the data read from filepath
:param filepath:
:return: assembledf:
'''
sparkConf = init_spark_conf().setAppName("testNNClassifer")
sparkConf = sparkConf.set("xgboost.spark.ignoreSsl", True)
sc = init_nncontext(sparkConf)
sqlContext = SQLContext(sc)
if demo:
Expand Down