-
-
Notifications
You must be signed in to change notification settings - Fork 188
OpenCL GPU Routines
OpenCL is an open-source framework for writing programs that utilize a platform with heterogeneous hardware. Stan uses OpenCL to design the GPU routines for the Cholesky Decomposition and it's derivative. Other routines will be available in the future. These routines are suitable for programs which require solving large NxM
matrices (N>600
) such as algorithms that utilize large covariance matrices.
Users must have a valid OpenCL driver installed on their computer and a compiler which supports compilation of OpenCL. Mac's should already have the OpenCL driver installed. While the GPU code has not been tested on windows, you can attempt to run the program by installing the OpenCL drivers as specified in this guide. You can check if you system is set up properly using the clinfo
program. Ubuntu users with an Nvidia device can get the OpenCL driver through the nvidia-cuda-toolkit
using
apt update
apt install nvidia-cuda-toolkit clinfo
Those with AMD devices can install the OpenCL driver available through
apt install -y libclc-amdgcn mesa-opencl-icd clinfo
If your device is not supported by the current drivers available you can try Paulo Miguel PPA
add-apt-repository ppa:paulo-miguel-dias/mesa
apt-get update
apt-get install libclc-amdgcn mesa-opencl-icd
Users can check that their installation is valid by running clinfo.
To turn on GPU computation:
- Check and record what device and platform you would like to use with clinfo and record the device and platform index.
- Open a text file called make/local; if it does not exist, create one.
- Add these lines to the make/local file:
STAN_OPENCL=true
OPENCL_DEVICE_ID=${CHOSEN_INDEX}
OPENCL_PLATFORM_ID=${CHOSEN_INDEX}
where the user will replace ${CHOSEN_INDEX} with the index of the device and platform they would like to use.
Once you have done the above step, runTests.py
should execute with the GPU enabled. All tests will match the phrase *_opencl_*
and tests can be filtered such as
./runTests.py test/unit -f opencl
Home | Users | Developers