From 7e45ef255c37524b4b3f9672e924b8f2abec2668 Mon Sep 17 00:00:00 2001 From: Vladimir Ovsyannikov Date: Mon, 13 Jun 2022 15:09:07 +0200 Subject: [PATCH] configuration for OMP_NUM_THREADS and WEB_SERVER_WORKERS --- aws-sagemaker-hosted-scorer-cpp/README.md | 5 +++++ aws-sagemaker-hosted-scorer-cpp/py/scorer/mojo_cpp_scorer.py | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/aws-sagemaker-hosted-scorer-cpp/README.md b/aws-sagemaker-hosted-scorer-cpp/README.md index b0f0ff58..f6f9d915 100644 --- a/aws-sagemaker-hosted-scorer-cpp/README.md +++ b/aws-sagemaker-hosted-scorer-cpp/README.md @@ -57,6 +57,11 @@ docker run \ (the number of web server workers can be configured by setting the environment variable: `WEB_SERVER_WORKERS` in the docker run command) +Recommended parameters: +* `OMP_NUM_THREADS=8` and can be increased for long size texts. +* `cores/(2*OMP_NUM_THREADS) <= WEB_SERVER_WORKERS <= cores/OMP_NUM_THREADS` +* `OMP_NUM_THREADS*WEB_SERVER_WORKERS` MUST NOT exceed `cores` + Step 3: Use the following curl command to test the container locally: ``` diff --git a/aws-sagemaker-hosted-scorer-cpp/py/scorer/mojo_cpp_scorer.py b/aws-sagemaker-hosted-scorer-cpp/py/scorer/mojo_cpp_scorer.py index 3ae7010f..39d1ef62 100644 --- a/aws-sagemaker-hosted-scorer-cpp/py/scorer/mojo_cpp_scorer.py +++ b/aws-sagemaker-hosted-scorer-cpp/py/scorer/mojo_cpp_scorer.py @@ -58,9 +58,7 @@ def get_prediction(self, d_frame): @staticmethod def _set_omp_threads(): - os.environ['OMP_NUM_THREADS'] = str(max(1, int(os.cpu_count()/2))) - os.environ['OMP_SCHEDULE'] = 'STATIC' - os.environ['OMP_PROC_BIND'] = 'CLOSE' + os.environ['OMP_NUM_THREADS'] = str(min(8, int(os.cpu_count())/2)) class ScorerError(Exception):