# Linux

{% hint style="success" %}
**Updating RL Swarm to the CodeZero Environment**

Run `git pull`, then restart your swarm.

1. **Docker users:** Run `docker-compose run --rm --build -Pit swarm-cpu` or `docker-compose run --rm --build -Pit swarm-gpu`
2. **Script users:** Rebuild your venv by running: `rm -rf .venv && python -m venv .venv && source .venv/bin/activate`
   {% endhint %}

## Overview

This guide walks you through setting up RL Swarm on a Linux machine.

Linux provides the most stable and performant environment for RL Swarm, especially for users running NVIDIA GPUs. You can run RL Swarm via Docker for simplicity or directly through Python for more advanced experimentation.

### Prerequisites

Make sure your system meets the minimum requirements and that you also have any additional dependencies installed.&#x20;

* Ubuntu 22.04+
* A 64-bit arm64 or x86 CPU with at least 32 GB RAM, or an officially supported NVIDIA GPU (3090, 4090, 5090, A100, H100)
* Python 3.10+
* [Docker](https://www.docker.com/) installed and configured
* Stable internet connection
* [Git](https://git-scm.com/install/) installed

### Installing Dependencies

First, update your package lists and install all required dependencies:

```bash
sudo apt update
```

```bash
sudo apt install -y python3 python3-venv python3-pip curl wget git docker.io build-essential
```

Next, start and enable the Docker service so it launches automatically on boot using the following commands:

```bash
sudo systemctl enable docker
```

```bash
sudo systemctl start docker
```

{% hint style="success" %}
You can verify Docker is running with `sudo docker info`.&#x20;

If this command returns information about the Docker daemon, it's running successfully.&#x20;
{% endhint %}

#### Configuring Docker

If you are using Docker Desktop, ensure that enough memory is allocated to containers. You can do this by going to **Settings > Resources > Advanced > Memory Limit** and setting the memory value to the highest available value.

{% hint style="info" %}
If you installed Docker through `apt`, make sure the daemon is active (as above) before running RL Swarm.
{% endhint %}

To check if you can run containers, run the following command to print a 'hello' message. If you see a success message, your installation is good to go.

```bash
sudo docker run hello-world
```

#### Clone the RL Swarm Repository

1. Navigate to your home directory and clone the RL Swarm GitHub repository using this command:

```bash
git clone https://github.com/gensyn-ai/rl-swarm.git
```

2. Then move into the project folder:

```bash
cd rl-swarm
```

### Run RL Swarm

Depending on your hardware, you can run RL Swarm in either **CPU** or **GPU** mode.

{% tabs %}
{% tab title="CPU-Only" %}
For CPU-only setup:

```bash
docker compose run –rm –build -Pit swarm-cpu
```

{% endtab %}

{% tab title="GPU-Only" %}
For GPU-enabled setup (officially supported on NVIDIA devices):

```bash
docker compose run –rm –build -Pit swarm-gpu
```

{% hint style="warning" %}
GPU mode requires NVIDIA drivers and CUDA toolkit properly installed.
{% endhint %}
{% endtab %}
{% endtabs %}

<div data-with-frame="true"><figure><img src="https://1034405018-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIcazOdplbOmP4R0T7sG8%2Fuploads%2FL7K5V5vz218KIXj5n9tk%2Frl_swarm_initial_spin_up.png?alt=media&#x26;token=7afb4980-3cca-4f39-b209-668d15093287" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
If you encounter an error saying “`docker-compose: command not found`”, use “`docker compose`” (without the hyphen) instead.
{% endhint %}

#### Log into RL Swarm

When you start RL Swarm, it will open a browser window automatically pointing to `http://localhost:3000.`

{% hint style="info" %}
If the browser does not open automatically, navigate to that address manually.
{% endhint %}

You will see the RL Swarm login screen powered by Alchemy. From here, you can log in using your preferred method such as Google or email.

<div data-with-frame="true"><figure><img src="https://1034405018-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIcazOdplbOmP4R0T7sG8%2Fuploads%2FwifzknxWLNIBoOKsirKE%2Fgensyn_login_screen.png?alt=media&#x26;token=66386835-d462-4681-b1fc-59dafd654372" alt=""><figcaption></figcaption></figure></div>

After login, a `swarm.pem` file will be created in your repository folder. This identifies your peer on the Gensyn Testnet.

***

### Joining the new RL-Swarm Environment (CodeZero)

#### Updating via git pull

First, start by running `git pull` to fetch the latest changes to RL Swarm.&#x20;

#### Launching after Updating

There are two launch paths.

1. **Launching with Docker:** If you are using Docker, you can restart your swarm after updating via `git pull` by using one of the two following commands:

```bash
docker-compose run --rm --build -Pit swarm-cpu
docker-compose run --rm --build -Pit swarm-gpu
```

2. **Launching with Shell Script:** If you are using the `run_rl_swarm.sh` script, you must remove your old virtual environment and create a fresh one:

```bash
rm -rf .venv
python -m venv .venv
source .venv/bin/activate
/run_rl_swarm.sh
```

{% hint style="success" %}
In both cases, restart your swarm after updating.
{% endhint %}

***

#### Huggingface

If you would like to upload your model to Hugging Face, enter your Hugging Face access token when prompted. You can generate one from your Hugging Face account, under [Access Tokens](https://huggingface.co/docs/hub/en/security-tokens).

#### Verify your Node

Once logged in, your node will begin training automatically.

You can verify that your peer has successfully connected by visiting the [Gensyn Testnet Dashboard.](https://dashboard.gensyn.ai/) Your peer should appear in the active swarm list, and you can monitor training progress in real time.

<div data-with-frame="true"><figure><img src="https://1034405018-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIcazOdplbOmP4R0T7sG8%2Fuploads%2FDWHs4gYzjRqDnRQyjz8z%2Fimage.png?alt=media&#x26;token=5f706d42-3174-4469-9fef-1ee3c17fda80" alt=""><figcaption></figcaption></figure></div>

#### Optional: Experimental Mode (No Docker)

If you want to experiment with the [GenRL](https://github.com/gensyn-ai/genrl) library or the [configurable parameters](https://github.com/gensyn-ai/rl-swarm/blob/main/rgym_exp/config/rg-swarm.yaml), we recommend you run RL Swarm via shell script:

```
python3 -m venv .venv
source .venv/bin/activate
./run_rl_swarm.sh
```

{% hint style="info" %}
This method gives you access to GenRL’s configuration parameters and experimental features.
{% endhint %}

To learn more about experimental mode, check out our [getting started guide](https://github.com/gensyn-ai/genrl/blob/main/getting_started.ipynb) on Github.

### Troubleshooting

Refer to the multi-platform [RL Swarm Troubleshooting guide](https://docs.gensyn.ai/testnet/rl-swarm/troubleshooting) for unblocking information and fixes to common set-up issues.

{% hint style="success" %}
If you need additional support, you can [open a ticket](https://github.com/gensyn-ai/rl-swarm/issues) or [visit our Discord.](https://discord.com/invite/gensyn)
{% endhint %}
