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