惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
SecWiki News
SecWiki News
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
F
Fortinet All Blogs
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
O
OpenAI News
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
小众软件
小众软件
MongoDB | Blog
MongoDB | Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 最新话题
N
News | PayPal Newsroom
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
美团技术团队
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
V
Vulnerabilities – Threatpost
B
Blog RSS Feed
NISL@THU
NISL@THU
Security Latest
Security Latest
The Register - Security
The Register - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
S
SegmentFault 最新的问题
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
罗磊的独立博客
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
S
Security Affairs
月光博客
月光博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

蔡不菜和他的uU们

vLLM实践之个人AI基建——云端vLLM+SSH Tunnel+本地Cherry Studio 使用acme.sh进行阿里云域名SSL证书申请与部署自动化 OCR实践—PaddleOCR-VL-1.5 OCR实践—PaddlOCR-VL OCR新范式 2025年终总结-选择,未知的路 阿里云实例迁移、IP换绑 VS大型CPP项目调试,Debug模式,Release模式,附加到进程模式 NVIDIA相关库简介 2024已结算,万象新始,远虑近忧 OCR实践-Table-Transformer
CUDA TensorRT Python智能提示补全解决方案
()x · 2025-08-15 · via 蔡不菜和他的uU们

解决方案

解决方案来自 https://github.com/NVIDIA/TensorRT/issues/1714

pybind11-stubgen --ignore-all-errors tensorrt_bindings

这个是针对特定版本 8.6.1 才有的,由NVIDIA提供

在pypi上NVIDIA还提供了一些 bindings 应该是用来支持更新版本的TensorRT

image-20250815133733903

image-20250815133805806

安装 pybind11-stubgen 和 tensorrt_bindings

pip install pybind11-stubgen tensorrt_bindings

然后执行

pybind11-stubgen --ignore-all-errors tensorrt_bindings

会在执行路径下生成一个 stubs/tensorrt_bindings/tensorrt.pyi

我测试过,其实不按照bingdings包也可以,这个工具是基于提供的 动态库 tenssort.so 来生成类型文件,直接执行pybind11-stubgen --ignore-all-errors tensorrt 即可 ,关键是底层动态库

==有问题,欢迎大家留言、进群讨论或私聊:【群号:392784757】==

然后将这个文件路径加入到 settings.json中(拿vscode举例)

{
      "python.defaultInterpreterPath": "yourpath/envs/llm-quant/bin/python",
  "python.analysis.extraPaths": [
    "yourpath/stubs",
  ]
}

效果

未生成前

image-20250815143956709

生成后

image-20250815144034847

同样的针对 pycuda 和 cuda-python 也是如此操作

题外话:pycuda 和 cuda-python 区别

Both CUDA-Python and pyCUDA allow you to write GPU kernels using CUDA C++. The kernel is presented as a string to the python code to compile and run.

The key difference is that the host-side code in one case is coming from the community (Andreas K and others) whereas in the CUDA Python case it is coming from NVIDIA. There are syntactical differences of course, but you should be able to perform basic operations using either methodology.

CUDA Python allows for the possibility to have a “standardized” host api/interface, while still being able to use other methodologies such as Numba to enable (for example) the writing of kernel code in python.

This blog and the questions that follow it may be of interest.

FWIW there are other python/CUDA methodologies. numba, cupy, CUDA python, and pycuda are some of the available approaches to tap into CUDA acceleration from Python. CUDA Python can interoperate with most or all of them.

https://forums.developer.nvidia.com/t/cuda-python-vs-pycuda/216751

Unifying the CUDA Python Ecosystem | NVIDIA Technical Blog https://developer.nvidia.com/blog/unifying-the-cuda-python-ecosystem/

pybind11-stubgen --ignore-all-errors cuda.cudart
pybind11-stubgen --ignore-all-errors cuda.cuda

未生成前

image-20250815144641333
image-20250815144724725

生成后

image-20250815144539707

知识点

  1. .so / .pyd 代码底层实现

  2. Stub(存根) 是一个通用术语,指“只提供接口定义,不包含实现”的代码文件

  3. .pyi 是 Python 的“存根文件”(Stub File),它是一个纯类型注解文件,用于为 .py 或 .pyd(C 扩展)模块提供 类型提示信息。 为模块提供“类型签名”,供 IDE 和类型检查工具使用,从而实现智能提示,补全