Skip to content

High-performance library for approximate inference on discrete Bayesian networks on GPU and CPU

License

Notifications You must be signed in to change notification settings

mspronesti/baylib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

baylib C++ library

C++ version Build Build GPU License

Baylib is a parallel inference library for discrete Bayesian networks supporting approximate inference algorithms both in CPU and GPU.

Main features

Here's a list of the main requested features:

  • Copy-On-Write semantics for the graph data structure, including the conditional probability table (CPT) of each node
  • parallel implementation of the algorithms either using C++17 threads or GPGPUU optimization
  • GPGPU optimization implemented with opencl, using boost compute and CUDA.
  • template-based classes for probability format
  • input compatibility with the XDSL format provided by the SMILE library
  • cmake-based deployment

Currently supported algorithms

  • Gibbs Sampling - C++11 threads
  • Likelihood Weighting - C++11 threads
  • Logic Sampling - GPGPU with boost compute
  • Rejection Sampling - C++11 threads
  • Adaptive importance sampling - C++11 threads, GPGPU with boost compute
algorithm evidence deterministic nodes multi-threading GPGPU-OpenCL GPGPU - CUDA
gibbs sampling *
likelihood weighting
logic sampling
rejection sampling
adaptive importance sampling

*It's a very well-known limitation of the Gibbs sampling approach

Dependencies

  • cmake >= 2.8
  • boost >= 1.65
  • libtbb
  • [optional] ocl-icd-opencl
  • [optional] mesa-opencl-icd

In order to use the cuda algorithms the system must be cuda compatible and the relative cuda toolkit must be installed.

Under Linux, you can install the required dependencies using the provided script install_dependencies.sh as follows

 cd scripts/
 chmod u+x install_dependencies.sh
./install_dependencies.sh

Install baylib

Using the cmake FetchContent directives you can directly setup baylib as follows

include(FetchContent)

FetchContent_Declare(
        baylib
        GIT_REPOSITORY https://github.com/mspronesti/baylib.git
)

FetchContent_MakeAvailable(baylib)
# create your executable 
# and whatever you need for
# your project ...
target_link_libraries(<your_executable> baylib)

Alternatively under Linux or MacOS, you can run the provided script install.sh as follows

cd scripts/
chmod u+x install.sh
sudo ./install.sh

another option for the script is running the following commands (assuming you're in the root of the project):

mkdir build
cd build
cmake ..
make
sudo make install

You can now include baylib in your projects.

In the latter two cases, make sure your CMakeLists.txt looks like this

find_package(baylib)
# create your executable 
# and whatever you need for
# your project ...
target_link_libraries(<your_executable> baylib)

Usage

Baylib allows performing approximate inference on Bayesian Networks loaded from xdsl files or created by hand (either using named nodes or numeric identifiers).

Have a look at examples for more.

External references

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •