> For the complete documentation index, see [llms.txt](https://edhoang.gitbook.io/heurist-mining-guide-sd-v1.3.0-llm-v1.1.1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edhoang.gitbook.io/heurist-mining-guide-sd-v1.3.0-llm-v1.1.1/heurist-mining-guide.md).

# Heurist Mining Guide

## 0. Start with heurist

* Official Document: <https://docs.heurist.ai/>
* Twitter: <https://twitter.com/heurist_ai>
* Website: <http://heurist.ai/>
* Github: <https://github.com/heurist-network/miner-release>

## 1. Where to rent GPU?

To mine on @heurist\_ai, you will need a GPU. You can use your own GPU or rent from outside. My recommendation is using RTX 3xxx, 4xxx, A6000 and 6000ADA. Other GPU still be suitable for mining.

If you don’t have GPU or don’t want to use your own GPU, there are some place for you:

* @heurist\_ai: Team offers node rental. You don’t need to do anything, just pay money and get points. Team will take care the rest. Don’t need to read anymore, just head to <https://discord.gg/QssH9JjC> and create a ticket. Mod will reach you soon.
* <https://cloud.vast.ai/> : Most common marketplace for AI mining. Guide to rent: <https://twitter.com/Psyxology_/status/1775279233537130954>
* <https://console.akash.network/> : Onchain marketplace build on Cosmos network. Guide to rent: <https://mirror.xyz/0xC36A87666c505Fe695fc097d238725ff4d34877D/4aIgauH_MXe9oxYvUNgtaZIS0qcQdaXcZYBLbO3N8O4>
* <https://www.runpod.io/> : Other marketplace like vast.
* <https://clore.ai/marketplace> : Onchain marketplace like akash, build on their own network.

Some notice when you deploy GPU:

* You should use this docker/image: `pytorch/pytorch:2.2.0-cuda12.1-cudnn8-devel`. However other docker/image still fine.
* To run LLM you need 60GB storage, SD 80GB and if you want to run both 120GB
* CUDA = 12.1 or 12.2
* GPU minimum VRAM is 24GB
* LLM performance is affected by bandwidth. If u run llm, choose a strong bandwidth GPU.
* Vram of your GPU:

<figure><img src="/files/EgF7LBPfqYaLtEM60XG2" alt=""><figcaption></figcaption></figure>

* Optimal GPU: RTX3090, RTX4090 for 24GB Vram, A6000 and 6000ada for 40GB Vram model

## 2. Set up your node

* First prepare an EVM wallet. It can hold NFT to boost point. The multiplier show below

<figure><img src="/files/CcV2MMEKrD1ImFCMxDld" alt=""><figcaption></figcaption></figure>

&#x20;      Paste code on terminal: **right click**. Run code: **Enter**. End current task: **Ctrl + C**

* Open your terminal, install tmux with this command and open tmux (If u have already got it skip this):

`sudo apt update && sudo apt install tmux -y && tmux`

It should appear like this:

<figure><img src="/files/CnwPH2r8p3A32hjJw3FY" alt=""><figcaption></figcaption></figure>

* Then install these libraries:

`sudo apt update && sudo apt install python3-venv -y && sudo apt install curl -y && sudo apt install git -y`

* Then install anaconda:

`curl --output anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh && bash anaconda.sh`

&#x20;     **Ctrl C** then **enter** to skip reading their terms, then **type yes** to agree and **enter** to install. Finally type yes to finish

* Next active conda:

`conda init bash && source ~/.bashrc && conda create --name heurist-miner python=3.11 & conda activate heurist-miner`

&#x20;      It should appear like this&#x20;

<figure><img src="/files/rw1LP02WbZoYQoVhWaKq" alt=""><figcaption></figcaption></figure>

* Then install from heurist github and require lib:

`conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia && git clone https://github.com/heurist-network/miner-release && cd miner-release && pip install -r requirements.txt`

* Next create `.env` file:

`touch .env && apt install nano -y && nano .env`

* Then input your EVM wallet address. This wallet will store your point mining and will receive airdrop further, so store it carefully.

`MINER_ID_0=0xYourFirstWalletAddressHere`

`MINER_ID_1=0xYourSecondWalletAddressHere`

&#x20;      The number of miner id depends on how much GPU on your device. If u rent GPU like this, you will need 4 miner id

<figure><img src="/files/31P9Rft5dl49xCLPabKC" alt=""><figcaption></figcaption></figure>

`MINER_ID_0=0xYourFirstWalletAddressHere`

`MINER_ID_1=0xYourSecondWalletAddressHere`

`MINER_ID_2=0xYourThirdWalletAddressHere`

`MINER_ID_3=0xYourFourthWalletAddressHere`

&#x20;      Optional: You can add tag for your wallet by adding “-\<Tag>” after the wallet, it will help you to track performance later on dashboard

<figure><img src="/files/FKJmaihVhupbqMaRQCSC" alt=""><figcaption></figcaption></figure>

&#x20;      After that, **Ctrl + X** to exit file, **Y** to save file and **enter** to remain its name.

&#x20;      Optional: You can view what is in the file by using `cat` command.

`cat .env`

<figure><img src="/files/uvMF9NAhIu8Wv1DlYatb" alt=""><figcaption></figcaption></figure>

* Modify `config.toml`

`nano config.toml`

&#x20;      When:

* Your gpu not located in Asia: You should use sequence url: <http://sequencer-na.heurist.xyz/> . This server base in North America (New York). It can reduce your network latency

&#x20;      Change `base_url` to <http://sequencer-na.heurist.xyz/>. You can use **arrow** to move around file

<figure><img src="/files/vQSua0uOl0HaSu99KmmE" alt=""><figcaption></figcaption></figure>

* You have more than 1 GPU. This only apply to SD

&#x20;      Change `num_cuda_devices` to your number of GPU

<figure><img src="/files/YprEfzaDfq5CTjMyMt5D" alt=""><figcaption></figcaption></figure>

* You want to get more point. This only apply to LLM (Your GPU should be strong enough to handle this)

&#x20;      Increase `num_child_process` and `concurrency_soft_limit`

<figure><img src="/files/PNcr9Wfk5zuCIuU7n3OL" alt=""><figcaption></figcaption></figure>

&#x20;      Remember to **Ctrl + X** to exit file, **Y** to save file and **enter** to remain its name.

* For LLM: Finally, install these 2 libs:

`sudo apt install jq -y && sudo apt install bc -y`

## 3. Identity Wallet

After you have set up your GPU, now you need an Identity Wallet to authenticate every request sent by your miner. Each EVM wallet is only associated to one Identity Wallet. That mean you only need to do that for the first time

Remember:

* One reward wallet always binds to one identity wallet. Without it, you won't receive rewards for completed jobs
* Do not use the reward wallet as the identity wallet
* Do not hold any funds in the identity wallet
* Back up the seed phrase of the identity wallet. If you lose it, you need to sign an on-chain transaction from the reward wallet to recover.

&#x20;      To create Identity Wallet, run this cmd

`cd $HOME/miner-release && python3 ./auth/generator.py`

&#x20;      Then save your Identity Wallet information and press y. The number of Identity Wallets generated based on your number of EVM wallets in `.env`

<figure><img src="/files/OjWhl5H3jqPLMfXGFY3P" alt=""><figcaption></figcaption></figure>

&#x20;      If you change your GPU, when you run `python3 ./auth/generator.py` it will appear like this

<figure><img src="/files/PRQrNz0vFQXUAyPzgO64" alt=""><figcaption></figcaption></figure>

&#x20;      Then import your Identity Wallet seed phrase you have save before.

<figure><img src="/files/Kaw7JquNZjbfvn72VUj6" alt=""><figcaption></figcaption></figure>

&#x20;      Finally **press y** and **enter** and you are done.

&#x20;      Now head to [4. Run the miner](#id-4.-run-the-miner)

&#x20;      Optional: In case you change GPU and forget to save Identity Wallet seed phrase after your wallet have bound:

&#x20;      First, faucet ETH on zkSync Era Sepolia testnet by using these link

* <https://faucet.chainstack.com/>
* <https://faucet.quicknode.com/zksync/sepolia>

&#x20;      Or you can buy from

&#x20;      <https://testnetbridge.com/sepolia> (Use Arbitrum for optimal amount, 0.1$ in ETH is enough)

<figure><img src="/files/nLQsKyOD97TgAa0O6Zj5" alt=""><figcaption></figcaption></figure>

&#x20;      Then bridge from Sepolia to zkSync Era Sepolia by

&#x20;      <https://portal.zksync.io/bridge/?network=sepolia>

&#x20;      Then add zkSync Era Sepolia testnet to your wallet

&#x20;      <https://chainlist.org/chain/300>

&#x20;      Then open Heurist contract <https://sepolia.explorer.zksync.io/address/0x7798de1aE119b76037299F9B063e39760D530C10#contract>

&#x20;      Then choose **Write** and connect your wallet.

<figure><img src="/files/9mzbUqQK1Qor8kqr5pRi" alt=""><figcaption></figcaption></figure>

&#x20;      Then choose **mintandbind** and input your wallet

<figure><img src="/files/PMLI553wzkMu0ozNYcIb" alt=""><figcaption></figcaption></figure>

* rwAddress: your evm address . This must exactly the same with address you have connected to
* iwAddress: your Identity Wallet

&#x20;      Then write, accept fee and you are done

<figure><img src="/files/VfEDGd1fWzBFh9yQgW1i" alt=""><figcaption></figcaption></figure>

&#x20;     Repeat this step for all other wallets.

&#x20;     After that returned to the terminal. You can run again to check if your wallet is binding.

`python3 ./auth/generator.py`

<figure><img src="/files/VSIcUnNUaj8I5tIMVXyj" alt=""><figcaption></figcaption></figure>

## 4. Run the miner

Finally, you have finish set up everything. Congratulations! Now you just need only a few command to start mining on Heurist.

* For SD miner:

`python3 sd-miner.py`

&#x20;      If you want to run a lighter model, use this command. Although this will bring you less point, your GPU will take up less vram so that you can run more screen (However this is currently disable):

`python3 sd-miner.py --exclude-sdxl`

&#x20;     Finally type yes to install your model and let it cook.

&#x20;     In case your GPU is strong enough and you want to earn more points, create a new screen by pressing **Ctrl + B** then **press C** to create new window.

<figure><img src="/files/KPlUhgbMuXT2pDvNyjTr" alt=""><figcaption></figcaption></figure>

&#x20;     Then run

`cd miner-release && conda activate heurist-miner`

Then start the miner again. Remember to do this after you have installed model from your first screen. However it can crash your GPU, so be careful

&#x20;

For LLM miner:

`./llm-miner-starter.sh <your model id>`

Replace `<your model id>` with

`dolphin-2.9-llama3-8b` or `openhermes-2-pro-mistral-7b` if your GPU have >24GB VRAM (ex: RTX 3090, RTX 4090)

`openhermes-mixtral-8x7b-gptq` if your GPU have >40GB VRAM (ex: A6000, 6000ada)

Congratulations! Your node is running. Happy mining!

## 5. Update miner

If you are running older versions, update the miner:

`git checkout main && git restore . && git pull`

Then install all lib again

`pip install -r requirements.txt`

Then back to [3. Identity Wallet](#id-3.-identity-wallet) and follow instructions to bind your wallet.

## 6. Common question

What can I do if I change GPU and forget to save my previous Identity Wallet?

**Solution**: Run `python auth/generator.py --new 0xYourRewardWalletAddress` to create new Identity Wallet and return to [3. Identity Wallet](#id-3.-identity-wallet)

What can I do if I have bound my Identity Wallet, change GPU and forget to save my previous Identity Wallet?

**Solution**: In [3. Identity Wallet](#id-3.-identity-wallet) Use mintandbind function, `rwAddress` is your EVM wallet and `iwAddress` is your new Identity Wallet.

Why sometime I face up with 0.0 token/s for llm model? How can I fix it?

**Solution**: You can switch to other model to run

I face up with this error, how can i fix?

<figure><img src="/files/FpH9ORczuLIty1elwCcm" alt=""><figcaption></figcaption></figure>

**Solution**: Run `cat .env` to check your number of miner id, make sure about syntax

<figure><img src="/files/0hhWjMb7fGNcqPn8CCyG" alt=""><figcaption></figcaption></figure>

and number of id have to match number of GPU. Also `nano config.toml` to change `num_cuda_devices` to match number of your GPU

I face up with this error, how can i fix?

<figure><img src="/files/ceDsEptofLH7Ofsowkli" alt=""><figcaption></figcaption></figure>

**Solution**: run `nvidia-smi` to check if your GPU have enough VRAM. In case it has enough but this error still occur, you are mining with CPU. My advice is you should rent other GPU
