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

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

蔡不菜和他的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 和类型检查工具使用,从而实现智能提示,补全