Tencent /ncnn
ncnn is a high-performance neural network inference framework optimized for the mobile platform
★ 24,052⑂ 4,551👁 566⑃ 3,195● 3,916▤ 50
Download: android harmonyos ios macos linux windows webassembly watchos tvos visionos 预编译库 20261020 7e36d25android-20261020 ↓202610202026-10-20
+1
Daily
+29
Weekly
+110
Monthly
24,052
stars
4,551
forks
566
watchers
3,195
prs
3,916
issues
50
releases
README
!ncnn
ncnn
ncnn is a high-performance neural network inference framework optimized for mobile, embedded, and desktop deployment.
It has no third-party runtime dependencies, runs across CPU and Vulkan GPU backends, and provides tools such as pnnx for converting PyTorch and ONNX models to ncnn.
Developers can deploy deep learning models efficiently on phones, PCs, browsers, and edge devices.
ncnn is currently being used in many Tencent applications, such as QQ, Qzone, WeChat, Pitu, and so on.
ncnn 是一个面向移动端、嵌入式和桌面端部署优化的高性能神经网络推理框架。
ncnn 无第三方运行时依赖,支持 CPU 和 Vulkan GPU 后端,并提供 pnnx 等工具将 PyTorch 和 ONNX 模型转换为 ncnn 模型。
基于 ncnn,开发者可以将深度学习模型高效部署到手机、PC、浏览器和边缘设备上。
ncnn 目前已在腾讯多款应用中使用,如:QQ,Qzone,微信,天天 P 图等。
---
Quick Start
The recommended beginner path is PyTorch - pnnx - ncnn.
Install pnnx in a PyTorch environment
shell
pip3 install pnnx
Export a PyTorch model to ncnn
python
import torch
import torch.nn as nn
import pnnx
class Model(nn.Module):
def __init__(self):
super().__init__()
self.conv = nn.Conv2d(3, 8, 1)
self.relu = nn.ReLU()
self.fc = nn.Linear(8, 4)
def forward(self, x):
x = self.conv(x)
x = self.relu(x)
x = x.mean((2, 3))
return self.fc(x)
model = Model().eval()
x = torch.rand(1, 3, 224, 224)
pnnx.export(model, "model.pt", (x,))
This generates model.ncnn.param and model.ncnn.bin.
Run with ncnn C++ API
cpp
include "net.h"
ncnn::Net net;
net.load_param("model.ncnn.param");
net.load_model("model.ncnn.bin");
ncnn::Mat in(224, 224, 3);
auto ex = net.create_extractor();
ex.input("in0", in);
ncnn::Mat out;
ex.extract("out0", out);
Or use Python
python
import numpy as np
import ncnn
net = ncnn.Net()
net.load_param("model.ncnn.param")
net.load_model("model.ncnn.bin")
x = np.zeros((3, 224, 224), np.float32)
mat = ncnn.Mat(x)
ex = net.create_extractor()
ex.input("in0", mat)
ret, out = ex.extract("out0")
print(np.array(out).shape)
See pnnx, use ncnn with PyTorch or ONNX, Python API, and examples for complete workflows.
---
Community
技术交流 QQ 群
637093648 (超多大佬)
答案:卷卷卷卷卷(已满)
Telegram Group
Discord Channel
Pocky QQ 群(MLIR YES!)
677104663 (超多大佬)
答案:multi-level intermediate representation
他们都不知道 pnnx 有多好用群
818998520 (新群!)
---
Download & Build status
https://github.com/Tencent/ncnn/releases/latest
how to build ncnn library on Linux / Windows / macOS / Raspberry Pi3, Pi4 / POWER / Android / NVIDIA Jetson / iOS / WebAssembly / AllWinner D1 / Loongson 2K1000
Source
- Build for Android
- Build for Termux on Android
Android
Android shared
- Build for HarmonyOS with cross-compiling
HarmonyOS
HarmonyOS shared
- Build for iOS on macOS with xcode
iOS
iOS-Simulator
- Build for macOS
macOS
Mac-Catalyst
watchOS
watTop issues
#3811onnx2ncnn 失败33 comments · 2022-05-20#5后续是否会支持将 tensorflow pb模型转为ncnn的模型呢?30 comments · 2017-07-24#4811Convolution1D and Deconvolution1D layers20 comments · 2023-06-18#3466Fail to convert yolov5 (5.0 or 6.0) to ncnn model18 comments · 2021-12-29#4679行人重识别这个项目模型转为ONNX在转为NCNN后识别错误。17 comments · 2023-04-28#3866语音分帧的流式处理17 comments · 2022-05-31#1747修改backbone后的Yolact模型转ncnn,输出错误17 comments · 2020-05-09#3846in.substract_mean_normalize(mean_vals, norm_vals)报告空指针异常16 comments · 2022-05-26
Discussions
#7238YOLOVAL: Arena Breakout ONNX-to-ncnn CPU check + 32 examples (paid models)0 comments · 2026-11-04#7130DAT2 transformer (4x UltraSharp V2) running fully on the Android GPU with ncnn + Vulkan0 comments · 2026-10-16#7004SeedVR2-ncnn:SeedVR2 的 ncnn Vulkan C++ 实现与低显存实验0 comments · 2026-09-14#7002【腾讯犀牛鸟2026】ERNIE-Image ncnn Vulkan Port0 comments · 2026-09-14#7001Seedvr2在ncnn-valkan后端上的推理实现0 comments · 2026-09-13#6999[腾讯犀牛鸟2026 #6790] Qwen3-ASR-0.6B ncnn C++ 端到端移植与跨平台验证0 comments · 2026-09-13#6998【腾讯犀牛鸟2026】ERNIE-Image ncnn Vulkan Port0 comments · 2026-09-13#6997[2026 犀牛鸟] ncnn现已支持wan 2.2 TI2V 5B0 comments · 2026-09-12
Latest release
android harmonyos ios macos linux windows webassembly watchos tvos visionos 预编译库 20261020 7e36d25 20261020 2026-10-20编译版本,默认配置,android-ndk-r30,ohos-sdk-5.0.3,xcode 16.4,ubuntu-22.04,ubuntu-24.04,ubuntu-26.04,vs2015,vs2017,vs2019,vs2022,vs2026,emscripten-6.0.12 | file | content | arch | |---|---|---| |ncnn-full-source.zip |包含全部 submodule 代码的完整源码 | | |ncnn-android.zip | android 静态库/动态库 | armeabi-v7a + arm64-v8a + x86 + x86_64 + riscv64 | |ncnn-android-vulkan.zip | android 静态库/动态库,支持 GPU | armeabi-v7a + arm64-v8a + x86 + x86_64 + riscv64 | |ncnn-harmonyos.zip | harmonyos 静态库/动态库 | armeabi-v7a + arm64-v8a + x86_64 | |ncnn-harmonyos-vulkan.zip | harmonyos 静态库/动态库,支持 GPU | armeabi-v7a + arm64-v8a + x86_64