gymnasium_rs

crates.io Rust Python Docker codecov

Gymnasium API for Reinforcement Learning.

Overview

The workspace contains these packages:

Instructions

Usage in Rust

Add gymnasium as a Rust dependency to your Cargo.toml manifest.

toml [dependencies] gymnasium = { git = "https://github.com/AndrejOrsula/gymnasium_rs.git" }

Examples: gymnasium/examples/

Usage in Python

The Python module requires Rust and Cargo to compile extensions. Install them through your package manager or via https://rustup.rs.

Compile and install the gymnasium Python module by installing this project with pip.

bash pip3 install git+https://github.com/AndrejOrsula/gymnasium_rs.git

Examples: gymnasium_py/examples/

CLI tool

After cloning the repository, use cargo to run the gymnasium_cli binary.

```bash

Pass --help to show the usage and available options

cargo run --release --bin gymnasium_cli -- --help ```

Examples, Tests, and Benchmarks

Rust examples can be run with cargo. Python examples can be directly interpreted.

```bash

Rust

cargo run --release --example ${EXAMPLE}

Python

python3 gymnasium_py/examples/${EXAMPLE}.py ```

Tests and benchmarks can be run with cargo.

Python tests require pytest (can be installed as an optional dependency with pip3 install .[test]).

```bash

Tests (--features python enables Python tests with pytest)

cargo test --features python

Benchmarks

cargo bench ```

Docker

To install Docker on your system, you can run install_docker.bash to configure Docker with NVIDIA GPU support (only for Debian-based distributions).

bash .docker/host/install_docker.bash

Build Image

To build a new Docker image from Dockerfile, you can run build.bash as shown below.

bash .docker/build.bash ${TAG:-latest} ${BUILD_ARGS}

Run Container

To run the Docker container, you can use run.bash as shown below.

bash .docker/run.bash ${TAG:-latest} ${CMD}

Run Dev Container

To run the Docker container in a development mode (source code mounted as a volume), you can use dev.bash as shown below.

bash .docker/dev.bash ${TAG:-latest} ${CMD}

As an alternative for VS Code users familiar with Dev Containers, you can modify the included devcontainer.json to your needs.

Join Container

To join a running Docker container from another terminal, you can use join.bash as shown below.

bash .docker/join.bash ${CMD:-bash}

License

This project is dual-licensed to be compatible with the Rust project, under either the MIT or Apache 2.0 licenses.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.