Setup a Heurist Miner on Akash

In the realm of computing, a significant trend towards decentralization is unfolding, marking a departure from traditional, centralized models. This movement is exemplified by platforms such as the Akash Network or Io Net. The move towards decentralization is driven by a confluence of factors that underscore the limitations inherent in Web2 infrastructures. The traditional Web2 providers are becoming increasingly cumbersome to navigate and deploy. This complexity stems from several key issues:

  1. Centralization: The centralized nature of these systems introduces inefficiencies and bottlenecks, making them less adaptable to the dynamic needs of modern computing.

  2. GPU Scarcity: The availability of high-performance GPUs is severely limited, hindering the execution of compute-intensive tasks essential for advancements in ML/AI..

  3. Data Privacy Concerns: Centralized systems often pose significant risks to data privacy, raising concerns among users and organizations about the security of their information.

  4. Convoluted Pricing Structures: Pricing mechanisms are often opaque, making it difficult for users to understand and anticipate costs.

  5. Liquidity Issues: Users frequently face challenges in managing their deposited funds due to rigid and opaque financial structures.

Our team at Nirmata Labs has directly encountered the challenges posed by Web2 providers. Notably, we have faced: Approval Hurdles for GPU Access: The requirement to justify the need for specific GPU models through detailed written explanations, followed by a tedious approval process, severely limits our agility and responsiveness to project demands.

Limited Access to High-End GPUs: Many platforms do not offer access to top-tier GPU models, such as Nvidia's H100, A100, or RTX A6000, which are crucial for cutting-edge machine learning and AI projects.

Funds Withdrawal Complexities: Withdrawing funds from these platforms is often a cumbersome and lengthy process, requiring direct communication with the provider team and enduring waiting periods of 5-7 days for the funds to be returned to one's bank account.

Limited Customizability: Customizability options are starkly limited, with only a select few providers offering essential pre-installed tools such as Docker, Nvidia drivers, or the CUDA toolkit. The scarcity of options to pre-install machine learning models further exacerbates the challenge, stifling innovation and experimentation.

In contrast, Akash Network stands out for its full customizability, allowing users to tailor their instances precisely to their needs. It offers seamless deployment options, including the ability to pre-install machine learning models, providing a smoother and more efficient experience for developers and users alike while offering full decentralization, absolute liquidity, instant withdrawals and no approvals to rent any of their machines. In this article, we will take a look at how we can use Akash to set up a miner for Heurist.

Hardware and Software Requirements for running a Stable Diffusion Miner for Heurist:

  1. Nvidia Cards with at least 12 GB of VRAM

  2. CUDA Toolkit 12.1 or 12.2

  3. Nvidia GPU Drivers

  4. Miniconda3

Step 1: Connecting to the Console:

  • Visit Akash Network Console

  • Connect your wallet and click on the Deployments tab on the left hand side

  • Click on the Rent GPUs Option here:

Click on Rent GPUs
Click on Rent GPUs
  • In navigating through the setup, you'll encounter a configuration screen that prompts for several key inputs: the choice between a Docker Image or Operating System, the number of GPUs, the preferred GPU model, the quantity of CPU cores, as well as the Memory and Storage specifications. As a case in point, we've selected an Operating System tailored for AI Art or Stable Diffusion, which notably includes pre-installed Nvidia Drivers and the CUDA toolkit—vital components for our project. The RTX A4000 was our GPU of choice, owing to its robust VRAM capacity that's adept at running Stable Diffusion models with ease. For our testing phase, we opted for 16 CPU cores; however, configurations with 4 or 8 cores should suffice as well, considering the computation is predominantly GPU-centric. We rounded off our setup with 16 GB of Memory and 200 GB of Storage, leaving the advanced configuration settings untouched. This is a glimpse of what the setup screen encompasses:
Configuring Compute Setup
Configuring Compute Setup
  • Click on Deploy and then it will show a “waiting for bids” screen. Wait for a few minutes until the bids based on the GPUs available show up.

  • After the Bids show up, it will look like this:

Compute Bids
Compute Bids
  • Select the bid you like and click on the “Accept Bid” button at the top right.

  • Confirm the deployment by accepting the transaction for AKT in your Metamask wallet.

  • After confirming it will look like this:

Confirmed Deployment
Confirmed Deployment

Step 2: Initializing the Deployment

  • After Deployment is successful, your instance will automatically show up on your current tab with the “Events Tab” pre-selected.

  • The instance page will contain this:

  • It will show events setting up in the “Events Tab”, meaning Akash is installing the OS and the necessary drivers onto the instance. It typically takes a minute or two until the instance is configured for use.

  • After waiting for a few minutes, click on the “Shell” tab and it will give you this message once successfully configured:

  • It seems that our shell is set up and we can verify that the NVIDIA drivers and the CUDA toolkit are pre-installed by running this command in the shell:

nvidia-smi

  • A Successful installation will look like this:
Akash Console Shell
Akash Console Shell

Displayed is our configuration featuring an RTX 4000 equipped with 16GB of VRAM and the CUDA Toolkit version 12.2, in addition to the installed NVIDIA Drivers. This setup fulfills the prerequisites for operating a Heurist miner. With these specifications in place, we are now positioned to proceed with the installation of Miniconda.

Step 3: Installing Miniconda and other dependencies

  • We need to log into the root user so enter command:

    su -

  • Update and upgrade Linux Packages and Dependencies:

    apt-get update

    apt-get upgrade

  • Install wget, tmux and Neovim:

    apt-get install wget

    apt-get install neovim

    apt-get install tmux

Installing Miniconda:

Referenced from : Install Miniconda in 5 Steps

  • Create a directory for Minconda3:

    mkdir -p ~/miniconda3

  • Download the latest Miniconda Installation Script:

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh

  • Run the Install Script:

    bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3

    After the installation is finished, it will look like this:

  • Delete the Install Script:

    rm -rf ~/miniconda3/miniconda.sh

  • Add a conda initialize to your bash:

~/miniconda3/bin/conda init bash

  • Exit from the shell as we have to reconnect to it in order to initialize conda:

    exit

  • Click on the events tab after exiting, wait for 10 seconds and click on the “Shell'' tab again to reconnect to the shell.

Verifying the Installation and creating the conda environment:

After restarting the shell, run:

conda list

If Miniconda has been installed successfully, you will see this:

Creating the Environment:

  • To establish our environment, execute the following command and allow some time for the downloading and extraction of the necessary packages:

    conda create --name gpu-3-11 python=3.11

  • Create a new tmux session to activate the environment and activate the miner by running:

    tmux new -s heurist

  • Activate the environment once you have entered the tmux by running:

    conda activate gpu-3-11

  • Install the conda environment dependencies we need to run the miner (this will take ~5mins to install):

    conda install pytorch torchvision torchaudio pytorch-cuda=12.2 -c pytorch -c nvidia

Cloning the miner repository to access the miner:

  1. Clone the official repository by running:

    git clone https://github.com/heurist-network/miner-release

  2. Enter into the miner-release directory:

    cd miner-release

  3. Install the python dependencies needed to run the miner:

    pip install python-dotenv

    pip install -r requirements.txt

  4. After installing all the dependencies, configure your Miner ID to receive rewards by creating a .env file using an editor of your choice:

  5. For this tutorial we have chosen to use Neovim as our file editor but you are free to use nano, vi or vim as well.

  6. Create and open the .env file while we are still in the miner-release directory:

    nvim .env

  7. Configure your Miner ID in order to be eligible for incentives and rewards by entering your 0x EVM address into your .env file like this: MINER_ID_0=0xYourWalletAddressHere

  8. Exit Neovim

    Press your keyboard’s escape button, or

    Write :exit or :wq and press enter

  9. Make sure that after exiting Neovim we have the .env configured and we are still in tmux.

Finally, Running the Miner:

While we are still in tmux, run:

python3 sd-miner-v1.0.0.py

or

python sd-miner-v1.0.0.py

Note: Make sure you select the correct version by checking the directory. As of mid march 2024, 1.0.0 is the latest version for stable diffusion.

  1. After running the miner, you will be asked for a yes or no to install the miner’s packages so enter y or yes

  2. Soon the model will be ready and your tmux will show: No Model Updates Required. and then this: All model Files are up to date, Miner is ready.

  3. When you see these, it means that the Miner is ready and running so you can detach from the tmux by pressing CTRL + b at the same time on your keyboard and d right after.

  4. Now you can successfully exit your machine as your miner is up and running in the tmux session in the background.

The resultant effect is that we have rented a GPU on Akash and are now using it as a miner on the Heurist network, serving image creation via stable diffusion. Nirmaan will utilise Akash and other decentralised compute providers as part of our compute aggregator, enabling us to route jobs to the cheapest available compute.

Nirmaan's Middleware Layer
Nirmaan's Middleware Layer
Subscribe to ASXN Labs
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.