编译[Bug]——too few arguments for template template parameter “Tuple“ detected

项目场景:

当使用高版本的cuda去安装低版本pytorch,并且编译用低版本pytorch写的cuda算子时,或者说是VS的版本过高如2022和2019,都有可能会出现某个.h文件或者.c文件报错,如:

复制代码
error: too few arguments for template template parameter "Tuple" detected during instantiation of class "pybind11::detail::tuple_caster<Tuple, Ts...>

解决方案:

修改报错对应行的表达式,像我这里报错的是torch里的cast.h的文件,网络上关于这个cast.h的错误好像就是最多的,就去conda envs里的

复制代码
torch/include/pybind11/cast.h

在报错的前面加上下面的代码进行修改,提前定义这个tuple_caster

复制代码
template <template <typename...> class Tuple, typename... Ts>
class tuple_caster;

template <typename T1, typename T2> class type_caster<std::pair<T1, T2>>
    : public tuple_caster<std::pair, T1, T2> {};

template <typename... Ts> class type_caster<std::tuple<Ts...>>
    : public tuple_caster<std::tuple, Ts...> {};
相关推荐
callJJ9 天前
Volta + Claude Code 在 Windows 上的路径 Bug 复盘
windows·bug
xsc-xyc9 天前
记一次RK3568搭建NAS BUG:开发板插上 USB 移动硬盘没反应
bug
放风铃的兔子11 天前
我把 5 个 Python bug 投进 CubeSandbox 当沙盘 —— 从 envd 协议反编译到一键 RED→GREEN
bug·issue
zh_xuan11 天前
诡异Bug:输入框删除字符,却越删越多
android·bug
绘梨衣54712 天前
采集基类设计遇到的描述符bug
爬虫·python·bug
不吃鱼的羊12 天前
达芬奇工具Bug
bug
油炸自行车12 天前
【bug】Qt 6 Q_NAMESPACE 跨 DLL 链接错误:LNK2019 无法解析 staticMetaObject
数据库·c++·qt·bug·link2019·q_namespace_exp·namespaceexport
sxd200113 天前
Debian #1135514 bug引发的思考
网络·debian·bug
疏狂难除15 天前
X86-64 Assembly中printf 打印 float 和 double的bug的解决
bug·assembly
nashane16 天前
HarmonyOS 6学习:指南针“文图反向”Bug修复——从“北偏东”变“北偏西”的坐标系纠错
学习·华为·bug·harmonyos