How to Install Kimi-Audio 7B Instruct Locally

How to Install Kimi-Audio 7B Instruct Locally

Kimi-Audio is a robust open-source mannequin constructed to grasp and generate audio in a number of attention-grabbing methods. If you’re engaged on automated speech recognition, audio query answering, and even constructing interactive voice-based purposes, Kimi-Audio delivers a unified resolution backed by over 13 million hours of audio pretraining and a novel structure that blends acoustic and semantic audio processing. Along with being extremely correct, it’s state-of-the-art throughout a number of benchmarks, making it a critical mannequin for any developer or researcher in audio AI.

In this information, we’ll stroll you thru putting in Kimi-Audio regionally, so you possibly can discover its full potential proper by yourself machine.

Prerequisites

The minimal system necessities for working this mannequin are:

  • GPU: RTX A6000

  • Storage: 100GB (preferable)

  • Jupyter Notebook put in.

  • VRAM: 64GB

Step-by-step course of to put in and run Kimi Audio 7B Instruct

For the aim of this tutorial, we’ll use a GPU-powered Virtual Machine by NodeShift because it gives excessive compute Virtual Machines at a really reasonably priced value on a scale that meets GDPR, SOC2, and ISO27001 necessities. Also, it provides an intuitive and user-friendly interface, making it simpler for freshmen to get began with Cloud deployments. However, be happy to make use of any cloud supplier of your alternative and observe the identical steps for the remainder of the tutorial.

Step 1: Setting up a NodeShift Account

Visit app.nodeshift.com and create an account by filling in primary particulars, or proceed signing up along with your Google/GitHub account.

If you have already got an account, login straight to your dashboard.

Image-step1-1

Step 2: Create a GPU Node

After accessing your account, it is best to see a dashboard (see picture), now:

1) Navigate to the menu on the left aspect.

2) Click on the GPU Nodes possibility.

Image-step2-1

3) Click on Start to begin creating your very first GPU node.

Image-step2-2

These GPU nodes are GPU-powered digital machines by NodeShift. These nodes are extremely customizable and allow you to management completely different environmental configurations for GPUs starting from H100s to A100s, CPUs, RAM, and storage, in response to your wants.

Step 3: Selecting configuration for GPU (mannequin, area, storage)

1) For this tutorial, we’ll be utilizing 1x RTX A6000 GPU, nevertheless, you possibly can select any GPU as per the stipulations.

2) Similarly, we’ll go for 200GB storage by sliding the bar. You also can choose the area the place you need your GPU to reside from the out there ones.

Image-step3-1

Step 4: Choose GPU Configuration and Authentication technique

1) After deciding on your required configuration choices, you will see the out there GPU nodes in your area and in response to (or very near) your configuration. In our case, we’ll select a 1x RTX A6000 48GB GPU node with 64vCPUs/63GB RAM/200GB SSD.

Image-step4-1

2) Next, you will want to pick out an authentication technique. Two strategies can be found: Password and SSH Key. We suggest utilizing SSH keys, as they’re a safer possibility. To create one, head over to our official documentation.

Image-step4-2

Step 5: Choose an Image

The ultimate step is to decide on a picture for the VM, which in our case is Jupyter, the place we’ll deploy and run the inference of our mannequin utilizing Diffusers.

Image-step5-1

That’s it! You are actually able to deploy the node. Finalize the configuration abstract, and if it seems to be good, click on Create to deploy the node.

Image-step5-2

Image-step5-3

Step 6: Connect to lively Compute Node utilizing SSH

1) As quickly as you create the node, will probably be deployed in a couple of seconds or a minute. Once deployed, you will note a standing Running in inexperienced, which means that our Compute node is able to use!

2) Once your GPU reveals this standing, navigate to the three dots on the proper, click on on Connect with SSH, and duplicate the SSH particulars that seem.

Image-step6-1

As you copy the main points, observe the under steps to connect with the working GPU VM by way of SSH:

1) Open your terminal, paste the SSH command, and run it.

2) In some circumstances, your terminal could take your consent earlier than connecting. Enter ‘sure’.

3) A immediate will request a password. Type the SSH password, and try to be related.

Output:

Image-step6-2

Next, If you need to verify the GPU particulars, run the next command within the terminal:

!nvidia-smi

Step 7: Set up the mission setting with dependencies

Create a digital setting utilizing Anaconda.

conda create -n kimi python=3.11 && conda activate kimi

Output:

Image-step7-1

2) Once you are contained in the setting, clone the official repository of Kimi-Audio.

git clone https://github.com/MoonshotAI/Kimi-Audio.git

3) Install mission dependencies.

pip set up -r necessities.txt

Output:

Image-step7-2

4) Login to huggingface-cli.

huggingface-cli login

Output:

Image-step7-3

5) Delete the previous glm4 listing and initialize and fetch submodules from the repository.

rm -rf kimia_infer/fashions/tokenizer/glm4
git submodule replace --init
ls kimia_infer/fashions/tokenizer/glm4/speech_tokenizer

Output:

Image-step7-4

6) Install and run jupyter pocket book.

conda set up -c conda-forge --override-channels pocket book -y
conda set up -c conda-forge --override-channels ipywidgets -y
jupyter pocket book --allow-root

7) If you are on a distant machine (e.g., NodeShift GPU), you will have to do SSH port forwarding with the intention to entry the jupyter pocket book session in your native browser.

Run the next command in your native terminal after changing:

<YOUR_SERVER_PORT> with the PORT allotted to your distant server (For the NodeShift server – you will discover it within the deployed GPU particulars on the dashboard).

<PATH_TO_SSH_KEY> with the trail to the placement the place your SSH secret’s saved.

<YOUR_SERVER_IP> with the IP tackle of your distant server.

ssh -L 8888:localhost:8888 -p <YOUR_SERVER_PORT> -i <PATH_TO_SSH_KEY> root@<YOUR_SERVER_IP>

Output:

Image-step7-5

After this copy the URL you acquired in your distant server:

And paste this in your native browser to entry the Jupyter Notebook session.

Step 8: Download and Run the mannequin

1) Open a Python pocket book inside Jupyter.

Image-step8-1

2) Install flash_attn and ninja.

!pip set up flash_attn --no-build-isolation
!pip set up ninja

3) Download mannequin checkpoints.

import sys
sys.path.insert(0, './Kimi-Audio')
import soundfile as sf
# Assuming the KimiAudio class is on the market after set up
from kimia_infer.api.kimia import KimiAudio
import torch # Ensure torch is imported if wanted for gadget placement

# --- 1. Load Model ---
# Load the mannequin from Hugging Face Hub
# Make certain you're logged in (`huggingface-cli login`) if the repo is personal.
model_id = "moonshotai/Kimi-Audio-7B-Instruct" # Or "Kimi/Kimi-Audio-7B"
gadget = "cuda" if torch.cuda.is_available() else "cpu" # Example gadget placement
# Note: The KimiAudio class may deal with mannequin loading in a different way.
# You may have to cross the model_id straight or obtain checkpoints manually
# and supply the native path as proven within the authentic readme_kimia.md.
# Please discuss with the principle Kimi-Audio repository for exact loading directions.
# Example assuming KimiAudio takes the HF ID or an area path:
attempt:
    mannequin = KimiAudio(model_path=model_id, load_detokenizer=True) # May want gadget argument
    mannequin.to(gadget) # Example gadget placement
besides Exception as e:
    print(f"Automatic loading from HF Hub may require particular setup.")
    print(f"Refer to Kimi-Audio docs. Trying native path instance (replace path!). Error: {e}")
    # Fallback instance:
    # model_path = "/path/to/your/downloaded/kimia-hf-ckpt" # IMPORTANT: Update this path if loading regionally
    # mannequin = KimiAudio(model_path=model_path, load_detokenizer=True)
    # mannequin.to(gadget) # Example gadget placement

# --- 2. Define Sampling Parameters ---
sampling_params = {
    "audio_temperature": 0.8,
    "audio_top_k": 10,
    "text_temperature": 0.0,
    "text_top_k": 5,
    "audio_repetition_penalty": 1.0,
    "audio_repetition_window_size": 64,
    "text_repetition_penalty": 1.0,
    "text_repetition_window_size": 16,
}

Output:

Image-step8-2

Image-step8-3

4) Finally, run the mannequin along with your desired immediate.

asr_audio_path = "asr.mp3"
# qa_audio_path = "qa_example.wav"

messages_asr = [
    {"role": "user", "message_type": "text", "content": "Please transcribe the following audio:"},
    {"role": "user", "message_type": "audio", "content": asr_audio_path}
]

# Generate solely textual content output
# Note: Ensure the mannequin object and generate technique settle for gadget placement if wanted
_, text_output = mannequin.generate(messages_asr, **sampling_params, output_type="textual content")
print(">>> ASR Output Text: ", text_output)

Input Audio: https://www.lightbulblanguages.co.uk/assets/audio/jpercent27aime.mp3

Output:

Image-step8-4

Conclusion

In this information, we explored the way to set up and run Kimi-Audio regionally, a flexible audio basis mannequin able to dealing with duties like ASR, audio captioning, and speech-driven conversations, all inside a unified framework. Its cutting-edge structure and large-scale pretraining make it a go-to alternative for builders pushing the boundaries of audio AI. To streamline this expertise, NodeShift Cloud gives the best setting for deploying and experimenting with fashions like Kimi-Audio, providing GPU-powered infrastructure, simple setup, and scalable assets so you possibly can focus extra on constructing and fewer on configuring.

For extra details about NodeShift:

HI-FI News

by way of DEV Community https://dev.to

April 29, 2025 at 06:48PM