How to Set Up a Miner on NI Compute (SN27)?

Feb 10, 2025

💻 Getting Started

NI Compute (SN27) is a decentralized compute network where contributors can offer their GPU power and earn rewards. Here’s a comprehensive guide to getting started as a miner on NI Compute (SN27).

📌 What You’ll Need to Begin

  • Hardware: GPUs like NVIDIA H200, H100 & A100 (see GPU scoring below).

  • Software: Ubuntu 22.04 (recommended) or higher, Python 3.10 or higher

  • Network Access: Ensure an open SSH port and proper firewall setup. Important to Note: Each UID is limited to one external IP. Port 4444 is to be opened so your miner can be allocated properly unless specified in PM2 below.

  • $TAO: To register your hotkey.

  • Wandb API Key: For tracking miner performance.

🌐 Step-by-Step Miner Setup

Install Docker

A Docker environment is required for miner resource allocation:

  1. Install Docker on Ubuntu: Official Docs

sudo apt-get update
sudo apt-get install docker.io
sudo docker run hello-world
  1. Verify Docker:

docker run hello-world

This should display a confirmation message with no errors.

Install Bittensor

  1. Run the one-line installer:

/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh>)"
  1. Verify Installation:

btcli --help

If you get a command-not-found error, add Bittensor to your PATH:

echo 'export PATH=$PATH:$(python3 -m site --user-base)/bin' >> ~/.bashrc
source ~/.bashrc

Which will give you an output similar to below:

usage: btcli <command> <command args>
bittensor cli v6.9.4
positional arguments:
{subnets,s,subnet,root,r,roots,wallet,w,wallets,stake,st,stakes,sudo,su,sudos,legacy,l,info,i}
subnets (s, subnet)
Commands for managing and viewing subnetworks.
root (r, roots) Commands for managing and viewing the root network.
wallet (w, wallets)
Commands for managing and viewing wallets.
stake (st, stakes) Commands for staking and removing stake from hotkey accounts.
sudo (su, sudos) Commands for subnet management
legacy (l) Miscellaneous commands.
info (i) Instructions for enabling autocompletion for the CLI.
options:
-h, --help show this help message and exit
--print-completion {bash,zsh,tcsh}
Print shell tab completion script

See Bittensor’s documentation for alternative installation instructions. Bittensor Documentation

Create or Regenerate Keys

  1. Create new coldkey (stores funds):

btcli w new_coldkey
  1. Create new hotkey (used for daily operations e.g. mining/validating/registration):

btcli w new_hotkey
  1. Regenerate existing keys if needed (to import them on this machine):

btcli w regen_coldkeypub #see below
btcli w regen_coldkey
btcli w regen_hotkey

Tip: For security, you can generate your coldkey on a secure offline machine and only load the public portion onto your miner or validator servers.

Clone and Install Compute Subnet

  1. Clone the repository:

git clone <https://github.com/neuralinternet/compute-subnet.git>
cd compute-subnet
  1. Install dependencies: required Python packages.

python3 -m pip install -r requirements.txt
python3 -m pip install --no-deps -r requirements-compute.txt
python3 -m pip install -e .
  1. In case you have missing requirements: Install additional system libraries.

sudo apt -y install ocl-icd-libopencl1 pocl-opencl-icd

CUDA Toolkit and GPU Drivers

Tip: If Nvidia toolkit and drivers are already installed on your machine, scroll down to step 5 to verify then move on to the docker CUDA support.

  1. Download the latest CUDA from NVIDIA's official page.

  2. Install (example for Ubuntu 22.04 (Dec. 2024)):

wget <https://developer.download.nvidia.com/compute/cuda/12.3.1/local_installers/cuda-repo-ubuntu2204-12-3-local_12.3.1-545.23.08-1_amd64.deb>
sudo dpkg -i cuda-repo-ubuntu2204-12-3-local_12.3.1-545.23.08-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-3-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-3
sudo apt-get -y install cuda-drivers
  1. Set environment variables:

echo "" >> ~/.bashrc
echo 'export CUDA_VERSION=cuda-12.3' >> ~/.bashrc
echo 'export PATH="$PATH:/usr/local/$CUDA_VERSION/bin"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH="/usr/local/$CUDA_VERSION/lib64:$LD_LIBRARY_PATH"' >> ~/.bashrc
source ~/.bashrc
  1. Reboot to finalize changes:

sudo reboot
  1. Verify driver and CUDA:

nvidia-smi
nvcc --version

The output of which should look something like:

+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06 Driver Version: 545.29.06 CUDA Version: 12.3 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA RTX Off | 00000000:05:00.0 Off | Off |
| 30% 34C P0 70W / 300W | 400MiB / 4914000MiB | 4% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| No running processes found |
+---------------------------------------------------------------------------------------+
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Nov__3_17:16:49_PDT_2023
Cuda compilation tools, release 12.3, V12.3.103
Build cuda_12.3.r12.3/compiler.33492891_0

NVIDIA Docker Support

Enable GPU functionality within Docker containers:

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L <https://nvidia.github.io/nvidia-docker/gpgkey> | sudo apt-key add -
curl -s -L <https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list> \\
| sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt update
sudo apt-get install -y nvidia-container-toolkit
sudo apt install -y nvidia-docker2

WandB Setup

  1. Create a free WandB account: wandb.ai

  2. Obtain an API Key and place it into your .env file:

cd compute-subnet
read -p "Enter WanDB API key: " wandb_api_key && sed -e s/"your_api_key"/"${wandb_api_key}"/ .env.example > .env
  1. Monitor stats at WandB: neuralinternet/opencompute

PM2 Setup

PM2 Process Manager monitors the operation and helps keep your miner or validator running persistently.

sudo apt update
sudo apt install npm -y
sudo npm install pm2 -g

Confirm pm2 is installed and running correctly:

pm2 ls

Networking and Firewall

Open necessary ports:

  1. Install and configure ufw:

sudo apt install ufw
sudo ufw allow 4444
sudo ufw allow 22/tcp
sudo ufw allow 8091/tcp #can be altered to a port of your choice. See below in README.md
sudo ufw enable
sudo ufw status

Tip: You can open any ports: sudo ufw allow xxxx/tcp and use them as your axon.port default e.g. sudo ufw allow 8091/tcp and this port would be specified in your pm2 miner process arguments as --axon.port 8091. If you are using a cloud server it is a good idea to check with your provider if ports are open by default. If you can create your own network rules make sure these inbound rules are applied to the server. Ask your provider for assistance with this networking step.

  1. Add user to docker group (if not already):

sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl start docker
sudo apt install at # ensures certain dependencies for Docker
sudo service docker status # should show 'active (running)'

Registering Your Hotkey

You need $TAO tokens in your coldkey to register the hotkey on the chosen netuid.

  • Main Network (netuid = 27, known as finney):

btcli s register --subtensor.network finney --netuid 27
  • Test Network (netuid = 15, known as test):

btcli s register --subtensor.network test --netuid 15

If you get the error too many registrations this interval, wait for the next interval and retry.

Registration cost can be checked Here. Or check using the CLI w/ btcli s list (Cost is 'RECYCLE').

Running a Miner

The miner contributes GPU resources to the network. Make sure your ports are open and your environment is set up as described above.

General Miner Command:

pm2 start ./neurons/miner.py --name <MINER_NAME> --interpreter python3 -- \\
  --netuid 27 \\
  --subtensor.network finney \\
  --wallet.name <COLDKEY_NAME> \\
  --wallet.hotkey <HOTKEY_NAME> \\
  --axon.port 8091 \\

  • -netuid: Subnet ID (27 for main, 15 for test).

  • -subtensor.network: Your Bittensor chain endpoint.

    • Main: finney

    • Test: test

    • Or use a custom endpoint, e.g. subvortex.info:9944 (recommended)

  • -wallet.name & -wallet.hotkey: The coldkey/hotkey names you created above and used in registration (btcli's defaults are default and default but both can be freely customized)

  • -axon.port: default 8091 can be replaced with any port number allowed by ufw as instructed above to serve your axon. Important for proper functionality and miner<->validator communication.

  • -ssh.port: A port opened with UFW as instructed above under the Networking and Firewall section (e.g., 4444) used for allocating your miner via ssh.

Miner Options

  • -miner.whitelist.not.enough.stake: Whitelist validators lacking sufficient stake (default: False).

  • -miner.whitelist.not.updated: Whitelist validators not on the latest code version (default: False).

  • -miner.whitelist.updated.threshold: Quorum threshold (%) before starting the whitelist (default: 60).

Checking Miner Logs

To inspect your miner’s logs:

pm2 logs
pm2 monit
  • pm2 logs shows rolling log output.

  • pm2 monit provides a live interface with CPU usage, memory, etc.

Run pm2 logs to debug any issues and view information on your miner. Specifically, find your wandb run to view more live information. In the wandb project, you can view the scores you receive from validators.

pm2 miner logs:

You can view your scores through the Wandb run of a Validator:

Expand the stats section:

Find your miner UID:

🔧 Troubleshooting

No requests received (no ‘Challenge’ or ‘Specs’ events):

  • Check your open ports (default allocation port: 4444). Check your Axon port is open with your machine or cloud provider. Use pm2 describe <PROCCESS_NAME> and pm2 show <PROCCESS_NAME> to view the arguments you used to run your miner e.g. -axon.port and -ssh.port and check with sudo ufw status that the right ports are open with UFW as well.

  • Check your pm2 logs for any errors or tracebacks to help troubleshoot.

  • Ensure the miner is running properly and not blacklisted.

Deregistered unexpectedly:

  • Competition on the network is high; more powerful devices may outcompete you.

  • Connection or environment issues.

  • Make sure scripts and Docker containers are running stably.

🔧 GPU Recommendations

Performance-based rewards depend on the GPU’s compute power. Here's a list of all the GPUs that are supported on NI Compute (SN27).

💡 Tips for Success

  • Use in-house hardware for better control and rewards.

  • Recommended cloud providers: Oracle, Coreweave, Latitude.sh (use referral code: BITTENSOR27).

Setting up a miner on Subnet 27 is your gateway to decentralized compute. By contributing your GPU power, you play a vital role in enabling scalable, permissionless computing for machine intelligence. Ready to start? Dive in now! 🌐✨

Note: This article is a condensed version of the full documentation on our website. For complete details, click here.