arm-linux-gnueabihf 交叉编译 faiss、openblas、openmpi

1. 安装交叉编译工具链

可参考文章(272条消息) ubuntu20.04 arm-linux-gnueabihf交叉编译opencv4.7.0 与opencv-contrib-4.7.0_洪流之源的博客-CSDN博客

2. 安装cmake

faiss对cmake版本要求较高,可参考文章(272条消息) ubuntu20.04 arm-linux-gnueabihf交叉编译opencv4.7.0 与opencv-contrib-4.7.0_洪流之源的博客-CSDN博客

 3. 编译OpenBLAS

1)克隆源码

git clone https://github.com/xianyi/OpenBLAS.git -b v0.3.20

2)编译

脚本如下:

#!/bin/bash

set -e

cd OpenBLAS
INSTALL_DIR=install

if [ -d ${INSTALL_DIR} ]; then
  cd ${INSTALL_DIR}
  rm -rf *
  cd ..
else
  mkdir ${INSTALL_DIR}
fi

make CC=arm-linux-gnueabihf-gcc FC=arm-linux-gnueabihf-gfortran HOSTCC=gcc TARGET=ARMV7 BINARY=32
make PREFIX=./install_ install

4. 编译faiss

1)克隆源码

git clone https://github.com/facebookresearch/faiss.git -b v1.7.4

2)编译

脚本如下:

#!/bin/bash

set -e

cd faiss

BUILD_DIR=build

if [ ! -d "${BUILD_DIR}" ]; then
  mkdir -p ${BUILD_DIR}
fi

cd ${BUILD_DIR}
rm -rf *

GCC_COMPILER=arm-linux-gnueabihf
cmake -DCMAKE_C_COMPILER=${GCC_COMPILER}-gcc \
      -DCMAKE_CXX_COMPILER=${GCC_COMPILER}-g++ \
      -DFAISS_ENABLE_GPU=OFF \
      -DFAISS_ENABLE_PYTHON=OFF \
      -DCMAKE_INSTALL_PREFIX=install \
      -DMKL_LIBRARIES=/examples/shitu/faiss/OpenBLAS/install_/lib/libopenblas.so \
      -DBUILD_TESTING=OFF \
      ..

make -j$(nproc)
make install

5. 编译openmpi

1)下载源码

Open MPI: Version 4.1 (open-mpi.org)

 2)编译

脚本如下:

#!/bin/bash

set -e

cd openmpi-4.1.5

./configure --prefix="$(pwd)/install" \
            CC=arm-linux-gnueabihf-gcc \
            CXX=arm-linux-gnueabihf-g++ \
            --host=arm-linux-gnueabihf \
            --enable-script-wrapper-compilers \
            --disable-mpi-fortran \
            --enable-shared \
            --disable-dlopen

make -j$(nproc)
make install

猜你喜欢

转载自blog.csdn.net/weicao1990/article/details/130511554