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:
Centralization: The centralized nature of these systems introduces inefficiencies and bottlenecks, making them less adaptable to the dynamic needs of modern computing.
GPU Scarcity: The availability of high-performance GPUs is severely limited, hindering the execution of compute-intensive tasks essential for advancements in ML/AI..
Data Privacy Concerns: Centralized systems often pose significant risks to data privacy, raising concerns among users and organizations about the security of their information.
Convoluted Pricing Structures: Pricing mechanisms are often opaque, making it difficult for users to understand and anticipate costs.
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:
Nvidia Cards with at least 12 GB of VRAM
CUDA Toolkit 12.1 or 12.2
Nvidia GPU Drivers
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 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:
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:
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:
nvidia-smi
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:
Clone the official repository by running:
git clone https://github.com/heurist-network/miner-release
Enter into the miner-release directory:
cd miner-release
Install the python dependencies needed to run the miner:
pip install python-dotenv
pip install -r requirements.txt
After installing all the dependencies, configure your Miner ID to receive rewards by creating a .env
file using an editor of your choice:
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.
Create and open the .env file while we are still in the miner-release directory:
nvim .env
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
Exit Neovim
Press your keyboard’s escape button, or
Write :exit or :wq and press enter
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.
After running the miner, you will be asked for a yes or no to install the miner’s packages so enter y
or yes
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.
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.
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.