MiniCPM4.1-8B is the latest addition to the MiniCPM family that shatters the myth that powerful AI requires a massive highly-expensive infrastructure. Designed specifically for edge-side devices, it achieves a level of efficiency that makes it perfect for local deployment on your machine or even with consumer-grade GPUs for large-scale use. This isn’t a mere reduction in size; it’s a fundamental reinvention of the model’s core, with innovations spanning four key dimensions: model architecture, learning algorithms, training data, and inference systems. All of this is paired with a high-quality, meticulously curated training dataset, resulting in a compact yet incredibly capable model.
The inference process for this model is going to be bit unique as OpenBMB provides a customized CUDA inference framework CPM.cu to utilize the full efficiency of your hardware for the MiniCPM models. In this guide, we have breakdown the complete setup and inference process in simple steps.
Prerequisites
The minimum system requirements for running this model are:
- GPU: 1x RTX4090 or 1x RTX A6000
- Storage: 50 GB (preferable)
- VRAM: at least 16GB
- Anaconda installed
Step-by-step process to install and run MiniCPM 4.1 8B
For the purpose of this tutorial, we’ll use a GPU-powered Virtual Machine by NodeShift since it provides high compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. Also, it offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider of your choice and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
Step 2: Create a GPU Node
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the GPU Nodes option.
- Click on Start to start creating your very first GPU node.
These GPU nodes are GPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations for GPUs ranging from H100s to A100s, CPUs, RAM, and storage, according to your needs.
Step 3: Selecting configuration for GPU (model, region, storage)
- For this tutorial, we’ll be using 1x RTX A6000 GPU, however, you can choose any GPU as per the prerequisites.
- Similarly, we’ll opt for 200GB storage by sliding the bar. You can also select the region where you want your GPU to reside from the available ones.
Step 4: Choose GPU Configuration and Authentication method
- After selecting your required configuration options, you’ll see the available GPU nodes in your region and according to (or very close to) your configuration. In our case, we’ll choose a 1x RTX A6000 48GB GPU node with 64vCPUs/63GB RAM/200GB SSD.
2. Next, you’ll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Step 5: Choose an Image
The final step is to choose an image for the VM, which in our case is Nvidia Cuda.
That’s it! You are now ready to deploy the node. Finalize the configuration summary, and if it looks good, click Create to deploy the node.
Step 6: Connect to active Compute Node using SSH
- As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
- Once your GPU shows this status, navigate to the three dots on the right, click on Connect with SSH, and copy the SSH details that appear.
As you copy the details, follow the below steps to connect to the running GPU VM via SSH:
- Open your terminal, paste the SSH command, and run it.
2. In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3. A prompt will request a password. Type the SSH password, and you should be connected.
Output:
Next, If you want to check the GPU details, run the following command in the terminal:
!nvidia-smi
Step 7: Set up the project environment with dependencies
- Create a virtual environment using Anaconda.
conda create -n minicpm python=3.11 -y && conda activate minicpm
Output:
2. Install required dependencies.
pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cu121
pip install "ninja>=1.0.0"
pip install transformers
pip install accelerate==0.26.0
pip install --upgrade pip setuptools wheel
pip install --upgrade aiohttp
3. Clone the official repository of CPM.cu
and build the package.
git clone https://github.com/OpenBMB/cpm.cu.git --recursive && cd cpm.cu
python3 setup.py install
Output:
4. Login to Hugging Face with HF READ token.
This is a gated model, make sure to get access granted from the model card.
hf auth login
Output:
Step 8: Run the model
- To pass a detailed prompt with long context, create a text prompt file.
cd examples
echo "Write an article about Artificial Intelligence." > prompt.txt
2. Run the model for inference.
python3 minicpm4/test_generate.py --prompt-file prompt.txt
Output:
Conclusion
MiniCPM-4.1-8B proves that efficiency and power can go hand in hand, delivering state-of-the-art performance through innovations in architecture, training, data, and inference while remaining lightweight enough for local or GPU-based deployment. With the help of CPM.cu
, users can unlock the model’s full potential by leveraging optimized sparse attention, quantization, and CUDA-based acceleration. NodeShift makes this entire journey seamless by simplifying installation, setup, and environment management, ensuring that developers can focus on quick experimentation and results with pre-configured CUDA enabled GPUs.