Simple instructions to enable multithreading on Windows with clang-cl
and Microsoft Visual Studio C++ build tools
These instructions need proper user privileges (administrative privileges) for installing Build Tools for Visual Studio 2017.
Follow instructions found in https://wiki.python.org/moin/WindowsCompilers
Build Tools for Visual Studio 2017 https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
Install the defaults and restart computer
Anaconda https://www.anaconda.com/download/#windows Miniconda https://conda.io/miniconda.html
Example uses Python 3.6, but feel free to use Python 3.7 instead.
Minimum
conda create -n stan_clang python=3.6 numpy cython clangdev -c conda-forge
Toolset I frequently use (JupyterLab + Excel tools + tools for ArviZ)
conda create -n stan_clang python=3.6 numpy cython matplotlib scipy jupyter jupyterlab notebook ipython xarray netcdf4 openpyxl xlrd pandas clangdev -c conda-forge
To list all available environments
conda env list
conda activate stan_clang
For older conda distributions use
activate stan_clang
Clone pystan_windows_threading
git clone https://github.com/ahartikainen/pystan_windows_threading
cd pystan_windows_threading
Add clang-cl compiler option to distutils.cfg
step_1_add_distutils_cfg.bat
Replace _msvccompiler.py
& ccompiler.py
with clang-cl enabled files
step_2_enable_clangcl.bat
Minimum
pip install pystan
Install arviz for visualization
pip install pystan arviz
Done. Follow official instructions to enable multithreading on PyStan.
https://pystan.readthedocs.io/en/latest/threading_support.html
Minimum workflow
conda create -n stan_clang python=3.6 numpy cython clangdev git -c conda-forge -y
conda activate stan_clang
git clone https://github.com/ahartikainen/pystan_windows_threading
cd pystan_windows_threading
step_1_add_distutils_cfg.bat
step_2_enable_clangcl.bat
pip install pystan
Suggested workflow
conda create -n stan_clang python=3.6 numpy cython matplotlib scipy jupyter jupyterlab notebook ipython xarray netcdf4 openpyxl xlrd pandas clangdev git -c conda-forge -y
conda activate stan_clang
git clone https://github.com/ahartikainen/pystan_windows_threading
cd pystan_windows_threading
step_1_add_distutils_cfg.bat
step_2_enable_clangcl.bat
pip install pystan arviz
Minimum workflow
conda create -n stan_clang python=3.6 numpy cython clangdev git -c conda-forge -y && ^
conda activate stan_clang && ^
git clone https://github.com/ahartikainen/pystan_windows_threading && ^
cd pystan_windows_threading && ^
step_1_add_distutils_cfg.bat && ^
step_2_enable_clangcl.bat && ^
pip install pystan
Suggested workflow
conda create -n stan_clang python=3.6 numpy cython matplotlib scipy jupyter jupyterlab notebook ipython xarray netcdf4 openpyxl xlrd pandas clangdev git -c conda-forge -y && ^
conda activate stan_clang && ^
git clone https://github.com/ahartikainen/pystan_windows_threading && ^
cd pystan_windows_threading && ^
step_1_add_distutils_cfg.bat && ^
step_2_enable_clangcl.bat && ^
pip install pystan arviz
Run batch file
run_all.bat