> For the complete documentation index, see [llms.txt](https://ciferai.gitbook.io/fhe/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ciferai.gitbook.io/fhe/2.-setup-environment.md).

# 2. Setup Environment

Before installing and configuring **Cifer's FHE**, it's important to properly prepare your environment. Follow these steps to ensure a smooth setup process:

## Update Python

Cifer requires **Python 3.8** or later. To check your Python version:

{% code title="bash" %}

```bash
python --version
```

{% endcode %}

If Python is not installed or you need to upgrade, download and install the latest version from [python.org](https://www.python.org/downloads/).

## Set Up a Virtual Environment&#x20;

It's recommended to use a virtual environment to avoid conflicts with other Python projects:

{% code title="bash" %}

```bash
python -m venv cifer_env
```

{% endcode %}

### Activate the virtual environment:

* **On Linux or macOS:**

{% code title="bash" %}

```bash
source cifer_env/bin/activate
```

{% endcode %}

* **On Windows:**

{% code title="bash" %}

```bash
cifer_env\Scripts\activate
```

{% endcode %}

## Upgrade pip

Ensure you have the latest version of pip:

{% code title="bash" %}

```bash
pip install --upgrade pip
```

{% endcode %}

### Check GPU/TPU Availability (Optional)

If you plan to use GPU or TPU acceleration:

**For NVIDIA GPUs:**

{% code title="bash" %}

```bash
nvidia-smi
```

{% endcode %}

**For TPUs (on Google Cloud):**

{% code title="bash" %}

```bash
gcloud compute tpus list
```

{% endcode %}

### Set Up Cloud Environment (for Collaboration Mode)

If you're planning to contribute your encrypted data as part of a collaborative Federated Learning.

1. Ensure you have access to a cloud platform (e.g., AWS, Google Cloud, Azure).
2. Set up firewall rules to allow communication on the required ports.
3. Prepare a shared storage solution for model checkpoints (e.g., S3, Google Cloud Storage).

### Prepare Your Dataset / Model

Organize your dataset or model as follows:

* Split the data into appropriate training and validation sets as needed.
* Store the raw files in a directory accessible to your local environment or the FHE client.

{% hint style="info" %}
**Important:** \
The data must be **preprocessed and converted into numerical array format** prior to encryption. \
Cifer's FHE uses `.npz` as the standard input format. You will find detailed `.npz` preparation steps in the [**Configuration**](/fhe/4.-dataset-and-model-preparation.md) section.
{% endhint %}

### Review System Requirements

Double-check that your system meets all the requirements listed in the previous section, including RAM, storage, and any specific hardware needs.
