Skip to content
/ drla Public

C++ Deep Reinforcement Learning Agent library

License

Notifications You must be signed in to change notification settings

benborder/drla

Repository files navigation

DRLA - Deep Reinforcement Learning Agent Library

The DRLA library is a C++ Deep Reinforcement Learning Agent based on libtorch (pytorch C++ API). The motivation for this project is to provide general DRL agents with common interfaces for use in C++ applications and environments, allowing training and running solely within the C++ runtime.

Note: This library is still in development and not yet considered stable, with features, potential optimisations, design improvements and bug fixes ongoing.

Features

  • Agent interfaces to integrate with environments and your project
  • Multi threaded async environment functionality
  • Model-free On-Policy rollout based algorithms (PPO, A2C)
  • Model-free Off-Policy replay based algorithms (DQN, SAC)
  • Model-based Monte-Carlo tree search algorithms (MuZero)
  • Hybrid Model-free and Model-based algorithms (Dreamer)

Example

See the following repositories for examples on how to use this library:

Dependencies

The library has been designed to have minimal dependencies with the only dependencies for the core library:

  • libtorch (build and runtime)
  • spdlog (build)
  • Compiler with C++17 support
  • CMake 3.14 or newer (CMake 3.22 is required for using presets)

Additional auxillary functionality such as config json serialisation and helper classes require the following libraries:

Building and Using

Install libtorch at /usr/local/libtorch and ensure cmake is also installed. There are two methods for including the library in your cmake project.

  1. Installing and using cmake find_package.
  2. Using FetchContent to obtain the library as a subproject.

For both options make sure to add drla::drla to your projects target_link_libraries. To use the auxillary functionality also add the drla::aux target.

Set BUILD_AUXILIARY=OFF in cmake to skip building the auxiliary library.

1. Install and find_package

Build and install DRLA

cmake --preset release
cmake --build --preset release --target install --parallel 8

Include in your cmake project via find package find_package(drla).

2. FetchContent subproject

Add the following to your cmake project:

FetchContent_Declare(
	drla
	GIT_REPOSITORY https://github.com:benborder/drla.git
	GIT_TAG        master
)
FetchContent_MakeAvailable(drla)