From efeb3114675efcc4e761c49ad5c64e2fe9bca1fc Mon Sep 17 00:00:00 2001 From: Stoff Audio LLC <94483749+StoffAudioLLC@users.noreply.github.com> Date: Mon, 8 May 2023 12:56:18 -0400 Subject: [PATCH 1/6] Added CPP options Added configurable openCL/multicore CPU vars when building the model. Requires changes to cmdstanpy to work. --- python/setup.py | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/python/setup.py b/python/setup.py index 20b7c69ad..ea27d0f6f 100644 --- a/python/setup.py +++ b/python/setup.py @@ -8,7 +8,8 @@ from pathlib import Path from shutil import copy, copytree, rmtree from typing import List - +import cmdstanpy.utils as utils +print(utils.cmdstan_path()) from setuptools import find_packages, setup, Extension from setuptools.command.build_ext import build_ext from setuptools.command.build_py import build_py @@ -18,12 +19,14 @@ MODEL_DIR = "stan" MODEL_TARGET_DIR = os.path.join("prophet", "stan_model") - +MODEL_GPU = False +MODEL_MULTI_CORES = False CMDSTAN_VERSION = "2.26.1" BINARIES_DIR = "bin" BINARIES = ["diagnose", "print", "stanc", "stansummary"] TBB_PARENT = "stan/lib/stan_math/lib" TBB_DIRS = ["tbb", "tbb_2019_U8"] +OPEN_CL = "-L"+"\"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/lib/Win32/OpenCL.lib\"" def prune_cmdstan(cmdstan_dir: str) -> None: @@ -105,12 +108,40 @@ def build_cmdstan_model(target_dir): target_dir: Directory to copy the compiled model executable and core cmdstan files to. """ import cmdstanpy - + if MODEL_GPU and MODEL_MULTI_CORES: + cpp_options = { + 'STAN_THREADS': True, + 'STAN_CPP_OPTIMS': True, + 'STAN_OPENCL': True, + 'OPENCL_DEVICE_ID': 0, + 'OPENCL_PLATFORM_ID': 0, + "PRECOMPILED_HEADERS":False, + 'LDFLAGS': OPEN_CL+' -lOpenCL' + + } + elif MODEL_MULTI_CORES: + cpp_options = { + 'STAN_THREADS': True, + 'STAN_CPP_OPTIMS': True, + + } + elif MODEL_GPU: + cpp_options = { + 'STAN_CPP_OPTIMS': True, + 'STAN_OPENCL': True, + 'OPENCL_DEVICE_ID': 0, + 'OPENCL_PLATFORM_ID': 0, + "PRECOMPILED_HEADERS":False, + 'LDFLAGS': OPEN_CL+' -lOpenCL' + } cmdstan_dir = (Path(target_dir) / f"cmdstan-{CMDSTAN_VERSION}").resolve() install_cmdstan_deps(cmdstan_dir) model_name = "prophet.stan" target_name = "prophet_model.bin" - sm = cmdstanpy.CmdStanModel(stan_file=os.path.join(MODEL_DIR, model_name)) + if MODEL_GPU or MODEL_MULTI_CORES: + sm = cmdstanpy.CmdStanModel(stan_file=os.path.join(MODEL_DIR, model_name), cpp_options=cpp_options) + else: + sm = cmdstanpy.CmdStanModel(stan_file=os.path.join(MODEL_DIR, model_name)) copy(sm.exe_file, os.path.join(target_dir, target_name)) # Clean up From 0050622f36b000329d43c13226a98e2c72201e03 Mon Sep 17 00:00:00 2001 From: Stoff Audio LLC <94483749+StoffAudioLLC@users.noreply.github.com> Date: Mon, 8 May 2023 12:57:14 -0400 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29b5e7a16..53c89d3a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Prophet: Automatic Forecasting Procedure +# Prophet: Automatic Forecasting Procedure With python OPENCL/Multi-Core options ![Build](https://github.com/facebook/prophet/workflows/Build/badge.svg) From c11d6a34416ed68fb0bf4bdda3f5b93491650d0f Mon Sep 17 00:00:00 2001 From: Stoff Audio LLC <94483749+StoffAudioLLC@users.noreply.github.com> Date: Thu, 11 May 2023 16:23:36 -0400 Subject: [PATCH 3/6] added section to check os --- python/setup.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/python/setup.py b/python/setup.py index ea27d0f6f..772fb776c 100644 --- a/python/setup.py +++ b/python/setup.py @@ -4,6 +4,7 @@ # LICENSE file in the root directory of this source tree. import os +import sys import platform from pathlib import Path from shutil import copy, copytree, rmtree @@ -26,9 +27,18 @@ BINARIES = ["diagnose", "print", "stanc", "stansummary"] TBB_PARENT = "stan/lib/stan_math/lib" TBB_DIRS = ["tbb", "tbb_2019_U8"] -OPEN_CL = "-L"+"\"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/lib/Win32/OpenCL.lib\"" - - +if sys.platform.startswith('win'): + try: + OPEN_CL = "-L\"" + "%CUDA_PATH%/lib/Win32/OpenCL.lib\"" + except KeyError: + raise OSError("Environment variable is not set") +elif sys.platform.startswith('linux'): + try: + OPEN_CL = "-L/usr/local/cuda-11.8/lib64/ -lOpenCL" + except KeyError: + raise OSError("Environment variable is not set") +else: + raise OSError("Unsupported platform: {}".format(sys.platform)) def prune_cmdstan(cmdstan_dir: str) -> None: """ Keep only the cmdstan executables and tbb files (minimum required to run a cmdstanpy commands on a pre-compiled model). From 3bb59c672bc3be88f5422c34562b0fc1ef9394fd Mon Sep 17 00:00:00 2001 From: Stoff Audio LLC <94483749+StoffAudioLLC@users.noreply.github.com> Date: Sun, 21 May 2023 11:45:41 -0400 Subject: [PATCH 4/6] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 53c89d3a3..cf6e9b80c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Prophet: Automatic Forecasting Procedure With python OPENCL/Multi-Core options - +[ + ![Donate with PayPal] + (https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png) +] +(https://www.paypal.com/donate?hosted_button_id=9ELH753DDE98Y) ![Build](https://github.com/facebook/prophet/workflows/Build/badge.svg) [![PyPI Version](https://img.shields.io/pypi/v/prophet.svg)](https://pypi.python.org/pypi/prophet) From 43e0b0b30e1bb58450a11e95b46eb52561bcf67a Mon Sep 17 00:00:00 2001 From: Stoff Audio LLC <94483749+StoffAudioLLC@users.noreply.github.com> Date: Sun, 21 May 2023 11:48:46 -0400 Subject: [PATCH 5/6] Update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index cf6e9b80c..e6d98ee58 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # Prophet: Automatic Forecasting Procedure With python OPENCL/Multi-Core options -[ - ![Donate with PayPal] - (https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png) -] -(https://www.paypal.com/donate?hosted_button_id=9ELH753DDE98Y) +[![Donate with PayPal](https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png)](https://www.paypal.com/donate?hosted_button_id=9ELH753DDE98Y) ![Build](https://github.com/facebook/prophet/workflows/Build/badge.svg) [![PyPI Version](https://img.shields.io/pypi/v/prophet.svg)](https://pypi.python.org/pypi/prophet) From 8400baaae25aec9cfd0f2393a59a6192852f97d4 Mon Sep 17 00:00:00 2001 From: "Jonathan Stoff (Stoff Audio LLC)" <94483749+StoffAudioLLC@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:21:36 -0400 Subject: [PATCH 6/6] Update README.md removed button --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e6d98ee58..b68866423 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # Prophet: Automatic Forecasting Procedure With python OPENCL/Multi-Core options -[![Donate with PayPal](https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png)](https://www.paypal.com/donate?hosted_button_id=9ELH753DDE98Y) ![Build](https://github.com/facebook/prophet/workflows/Build/badge.svg) [![PyPI Version](https://img.shields.io/pypi/v/prophet.svg)](https://pypi.python.org/pypi/prophet)