# Linux

### If you are using a cloud server, you need to install Linux remote connection tools for deployment.

{% content-ref url="linux/installing-linux-remote-connection-tools" %}
[installing-linux-remote-connection-tools](https://hyperdust-foundation.gitbook.io/moss-ai-docs/archived/game/ai-gaming-quick-start/node-mining/run-a-moss-ai-inference-node/linux/installing-linux-remote-connection-tools)
{% endcontent-ref %}

## Ⅰ.  Basic Requirements <a href="#prerequisites" id="prerequisites"></a>

**1.CPU**: Minimum 4 cores, recommended 8 cores

**2.Memory**: > 16GB

**3.GPU(Single Card）**: Nvidia RTX 3060/Nvidia RTX 3080/Nvidia RTX 3090

**4.Hard Drive** >512GB

**5.Internet**: 5-10M

<mark style="color:red;">**6.Public Address**</mark><mark style="color:red;">: Mandatory</mark>

<mark style="color:red;">6.1 Static Public IP</mark>\ <mark style="color:red;">You need to have a static public IP to ensure that the inference node can be reliably accessed by external networks.</mark>

<mark style="color:red;">6.2 Public IP Direct Connection to Inference Node</mark>\ <mark style="color:red;">The public IP should be directly bound to the network interface of the inference node so that external networks can directly access the inference node via this IP. If there are routers or other networking devices in the network, you must have the capability to configure these devices. Port forwarding should be set up to accurately forward external access requests to the corresponding port of the inference node, ensuring that the inference interface can provide normal services externally.</mark>

**By meeting the above conditions, you can ensure the stability and availability of the inference node's access and services.**

## Ⅱ. Install Docker

#### **Prerequisites** <a href="#prerequisites" id="prerequisites"></a>

* Ensure your system supports Docker and has the NVIDIA driver installed to support GPU.

**1.Update Package Index**

{% code title="Copy code" %}

```bash
sudo apt-get update
```

{% endcode %}

**2.Install Required Packages**

{% code title="Copy code" %}

```bash
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
```

{% endcode %}

**3.Add Docker’s Official GPG Key**

{% code title="Copy code" %}

```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```

{% endcode %}

**4.Set Up Docker Stable Repository**

{% code title="Copy code" %}

```bash
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```

{% endcode %}

**5.Update Package Index Again**

{% code title="Copy code" %}

```bash
sudo apt-get update
```

{% endcode %}

**6.Install Docker CE**

{% code title="Copy code" %}

```bash
sudo apt-get install docker-ce
```

{% endcode %}

**7.Install NVIDIA Container Toolkit**

{% code title="Copy code" %}

```bash
sudo curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
```

{% endcode %}

{% code title="Copy code" %}

```bash
sudo curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
```

{% endcode %}

{% code title="Copy code" %}

```bash
sudo apt-get update
```

{% endcode %}

{% code title="Copy code" %}

```bash
sudo apt-get install -y nvidia-docker2
```

{% endcode %}

{% code title="Copy code" %}

```bash
sudo systemctl restart docker
```

{% endcode %}

**8.Start and Enable Docker Service**

{% code title="Copy code" %}

```bash
sudo systemctl start docker
```

{% endcode %}

{% code title="Copy code" %}

```bash
sudo systemctl enable docker
```

{% endcode %}

**9.Verify Installation**

{% code title="Copy code" %}

```bash
docker --version
```

{% endcode %}

<br>

## Ⅲ. Install  Docker Compose

Download the latest version of Docker Compose:

{% code title="Copy code" %}

```sh
sudo curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
```

{% endcode %}

Add executable permissions to the Docker Compose binary：

<pre class="language-sh" data-title="Copy code"><code class="lang-sh"><strong>sudo chmod +x /usr/local/bin/docker-compose
</strong></code></pre>

Test if the installation was successful：

{% code title="Copy code" %}

```sh
docker-compose --version
```

{% endcode %}

## Ⅳ.  Install Git

1.Update the existing package lists.

{% code title="Copy code" %}

```sh
sudo apt-get update
```

{% endcode %}

2.Install Git：

{% code title="Copy code" %}

```sh
sudo apt-get install git
```

{% endcode %}

2.After installation, run the following command to verify if the installation was successful:

{% code title="Copy code" %}

```sh
git --version
```

{% endcode %}

##

## Ⅴ. Deploy the HyperAGI Inference System

### Step 1: Clone the Code Repository

1.Open the terminal or command prompt, and clone the HyperAGI-setup-script GitHub repository:

{% code title="Copy code" %}

```sh
git clone https://github.com/xfangs/hyperAGI-setup-script.git
```

{% endcode %}

2.Navigate to the cloned code repository directory:

{% code title="Copy code" %}

```sh
cd hyperAGI-setup-script
```

{% endcode %}

### Step 2: Configure Environment Variables

1.Within the cloned code repository, there is a .env file where you can configure environment variables. Open the .env file using a text editor:

{% code title="Copy code" %}

```sh
nano .env
```

{% endcode %}

**2.Configure the variables PUBLIC\_IP and WALLET\_ADDRESS**

**PUBLIC\_IP**: This is the public IP address of your server. You can find it by running the following command in the terminal:

{% code title="Copy code" %}

```sh
curl ifconfig.me
```

{% endcode %}

Copy and paste the outputted IP address into the PUBLIC\_IP variable in the .env file.&#x20;

\
**WALLET\_ADDRESS**: This is your wallet address used for receiving and managing funds related to AI inference. Ensure you use a valid Ethereum wallet address and paste it into the WALLET\_ADDRESS variable in the .env file.&#x20;

Modify environment variables as necessary.

<figure><img src="https://2279354883-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQKOLPD4ViKheRmnU59nx%2Fuploads%2FkdRdrHWTsJWY5o6sWWHm%2F%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240721152129.png?alt=media&#x26;token=1eca937f-c4d3-4686-9dc8-f7787b10def8" alt=""><figcaption></figcaption></figure>

3.After making modifications, perform the following actions:&#x20;

Ctrl + O (to write changes).&#x20;

Ctrl + Enter (to save).&#x20;

Ctrl + X (to exit).

### Step 3: Pull Docker Images&#x20;

Ensure you have the latest Docker images by running the following command:

{% code title="Copy code" %}

```sh
docker-compose pull
```

{% endcode %}

### Step 4: Start the Service&#x20;

Run the following command to start the Docker Compose service:

{% code title="Copy code" %}

```sh
docker-compose up -d
```

{% endcode %}

The `-d` flag indicates that the service will run in the background.

### Step 5: Verify Deployment&#x20;

You can verify if the service is running correctly by checking the status of the containers:

{% code title="Copy code" %}

```sh
docker-compose ps
```

{% endcode %}

You should see a list of running containers. Ensure that the status of all services is 'running'.

<figure><img src="https://2279354883-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQKOLPD4ViKheRmnU59nx%2Fuploads%2FKFgYdbYDW3n6aEa33izf%2Fimage%20(4).png?alt=media&#x26;token=ec4d4ac2-79a9-49d1-a840-ea2211788fd8" alt=""><figcaption></figcaption></figure>

**Access to ports 5200 TCP and 5100 TCP needs to be enabled.**

### &#x20;**Additional Notes**

For further troubleshooting, check the logs for additional information if encountering any issues:

{% code title="Copy code" %}

```sh
docker-compose logs
```

{% endcode %}

For more advanced configurations, please refer to the docker-compose.yml file in the code repository.

## Conclusion&#x20;

#### By following these steps, you should be able to deploy and run the complete HyperAGI inference system using Docker Compose. If you encounter any issues or need further assistance, please refer to the documentation or seek support from [the community](https://t.me/realMOSSCoin).
