C++程序编译时的_GLIBCXX_USE_CXX11_ABI参数的值选择,适配昇腾Transformer推理加速库与LLM推理模型库

2024/1/19日更新

具体使用cxx11abi0 还是cxx11abi1 可通过python命令查询

import torch
torch.compiled_with_cxx11_abi()

若返回True 则使用 cxx11abi1,否则相反。

确定已安装G++

命令行输入

g++ -v

示例输出

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-linux-gnu/10.3.1/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl --without-cloog --enable-gnu-indirect-function --build=aarch64-linux-gnu --with-stage1-ldflags=' -Wl,-z,relro,-z,now' --with-boot-ldflags=' -Wl,-z,relro,-z,now' --disable-bootstrap --with-multilib-list=lp64 --enable-bolt
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.1 (GCC)

总结网络上的搜索结果,如果GCC版本大于5.1,那么_GLIBCXX_USE_CXX11_ABI参数都是1
如果要编译低版本的软件,_GLIBCXX_USE_CXX11_ABI参数需要设置为0

编译测试程序获取宏值

新建一个文件

vim test.cpp

将下面的代码复制进去,wq保存

#include <iostream>
using namespace std;

int main() {
    #ifdef _GLIBCXX_USE_CXX11_ABI
        cout << _GLIBCXX_USE_CXX11_ABI << endl; 
    #else
        cout << "not defined" << endl;
    #endif
}

使用g++进行编译

g++ -o test test.cpp

运行可执行文件

./test

这将会打印输出_GLIBCXX_USE_CXX11_ABI参数的值

安装对应的Transformer LLM推理模型库和Transformer推理加速库

示例版本:
Ascend-cann-llm_7.0.0_linux-aarch64_torch2.0.1-abi0.tar.gz
Ascend-cann-atb_7.0.0_linux-aarch64_abi0.run

小结

按照官方的方式得到_GLIBCXX_USE_CXX11_ABI参数的值是0
按照编译测试程序获取宏值的方式得到的参数值是1
不敢还是按照官方的来吧,选择0

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值