×

签到

分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

编译cntoolkit/sample/BANG,显示lcnrt有问题 解决中 李爽2023-08-22 23:22:29 回复 2 查看 使用求助
编译cntoolkit/sample/BANG,显示lcnrt有问题

【星空体育硬件产品型号】必填*:MLU220


【使用操作系统】必填*:Linux ubuntu 4.15.0-142-generic #146~16.04.1-Ubuntu SMP Tue Apr 13 09:27:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux



【使用驱动版本】必填*: v4.9.4


【使用AI框架】必填*:BANG语言


【出错信息】必填*:执行/usr/local/neuware/samples/BANG下的build.sh,大量报错,错误信息见日志

error_log.txt


【操作步骤】选填:修改并执行./env.sh,仅仅删除了TOOLCHAIN_ROOT,没有其他修改。该文件内容如下:
if [ -z "${NEUWARE_HOME}" ]; then
  export NEUWARE_HOME=/usr/local/neuware
fi
if [ -z "${TOOLCHAIN_ROOT}" ]; then
  export TOOLCHAIN_ROOT="" # 已经配置好交叉编译工具,工具正常使用
fi

export PATH=${NEUWARE_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${NEUWARE_HOME}/lib64:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=${NEUWARE_HOME}/lib:${LD_LIBRARY_PATH}

已修改build.sh,仅仅修改了CPU架构:TARGET_CPU_ARCH="aarch64-linux-gnu"和任务并行:make -j6:

#!/bin/bash
set -e

source env.sh

check_deb_package() {
    if [ -z "$(dpkg -l | grep ${1})" ]; then
        echo "Please sudo apt install ${1}"
        exit -1
    fi
}

check_rpm_package() {
    if [ -z "$(rpm -qa | grep ${1})" ]; then
        echo "Please sudo yum install ${1}"
        exit -1
    fi
}

# check dependency for build
if [ -f "/etc/os-release" ]; then
    source /etc/os-release
    if [ ${ID} == "ubuntu" ] || [ ${ID} == "debian" ]; then
        check_deb_package cmake
        check_deb_package ccache
        CMAKE=cmake
    elif [ ${ID} == "centos" ]; then
        check_rpm_package cmake3
        check_rpm_package ccache
        CMAKE=cmake3
    else
        echo "Not support build on this os!"
        exit -1
    fi
fi

export WORKSPACE=${PWD}
export PATH="/usr/lib/ccache:$PATH"

################################################################################
# NOTE: NEUWARE_ROUNDING_MODE
#
# This env variable used for setting the hardware computing rounding mode
# The related computing unit is ALU, NFU, WFU.
# The cncc will set NEUWARE_ROUNDING_MODE=5 defaultly.
#
# [NULL,5] - Rounding to nearest even (= CPU/GPU)
# [0]      - Rounding to to zero
# [1]      - Rounding to positive Inf
# [2]      - Rounding up
# [3]      - Rounding down
# [4]      - Rounding to negative Inf
################################################################################
export NEUWARE_ROUNDING_MODE=0

usage () {
    echo "USAGE: build.sh <options>"
    echo
    echo "       If need specify neuware path, please:"
    echo "       Firt, export NEUWARE_HOME where neuare installed"
    echo "         export NEUWARE_HOME=/path/of/your/neuware"
    echo "       Second, export TOOLCHAIN_ROOT if cross-compilation for aarch64-linux-gnu"
    echo "         export TOOLCHAIN_ROOT=/path/to/cross_toolchains"
    echo
    echo "OPTIONS:"
    echo "      -h, --help                     Print usage"
    echo "      <null>                         If no --mluxxx specified, default arch is cnfatbin which contain all mlu arch"
    echo "      --mlu1h8                       Build for target product MLU1H8: __BANG_ARCH__ = 110"
    echo "                                                                      __MLU_NRAM_SIZE__ = 256KB"
    echo "                                                                      __MLU_WRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_SRAM_SIZE__ = 0KB"
    echo "                                                                      cncc --bang-mlu-arch=tp_110, cnas --mlu-arch tp_110"
    echo "      --mlu100                       Build for target product MLU100: __BANG_ARCH__ = 100"
    echo "                                                                      __MLU_NRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_WRAM_SIZE__ = 1024KB"
    echo "                                                                      __MLU_SRAM_SIZE__ = 0KB"
    echo "                                                                      cncc --bang-mlu-arch=mtp_100, cnas --mlu-arch mtp_100"
    echo "      --mlu220                       Build for target product MLU220: __BANG_ARCH__ = 220"
    echo "                                                                      __MLU_NRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_WRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_SRAM_SIZE__ = 2048KB"
    echo "                                                                      cncc --bang-mlu-arch=mtp_220, cnas --mlu-arch mtp_220"
    echo "      --mlu270                       Build for target product MLU270: __BANG_ARCH__ = 270"
    echo "                                                                      __MLU_NRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_WRAM_SIZE__ = 1024KB"
    echo "                                                                      __MLU_SRAM_SIZE__ = 2048KB"
    echo "                                                                      cncc --bang-mlu-arch=mtp_270, cnas --mlu-arch mtp_270"
    echo "      --mlu290                       Build for target product MLU290: __BANG_ARCH__ = 290"
    echo "                                                                      __MLU_NRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_WRAM_SIZE__ = 512KB"
    echo "                                                                      __MLU_SRAM_SIZE__ = 2048KB"
    echo "                                                                      cncc --bang-mlu-arch=mtp_290, cnas --mlu-arch mtp_290"
    echo "      -d, --debug                    Build test case with debug mode"
    echo
}

# Handle build mode
BUILDDIR="./build"
if [ ! -d "$BUILDDIR" ]; then
  mkdir "$BUILDDIR"
fi

# default target mlu arch is CNFATBIN with MLU220/MLU270/MLU290 inside
TARGET_CPU_ARCH="aarch64-linux-gnu"
TARGET_MLU_ARCH="CNFATBIN"
CXX_COMPILER="${TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-g++"

C_COMPILER="${TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-gcc"

SYSROOT="$(find ${TOOLCHAIN_ROOT} -name "libc" -type d)"

# NOTE: setup cross toolchain as you need
# TARGET_CPU_ARCH="aarch64-linux-gnu"
# CXX_COMPILER="${TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-g++"
# C_COMPILER="${TOOLCHAIN_ROOT}/bin/aarch64-linux-gnu-gcc"
# SYSROOT="$(find ${TOOLCHAIN_ROOT} -name "libc" -type d)"

if [ $# != 0 ]; then
  BUILD_MODE="release"
  while [ $# != 0 ]; do
    case "$1" in
      -h | --help)
          usage
          exit 0
          ;;
      --mlu1h8)
          TARGET_MLU_ARCH="1H8"
          shift
          ;;
      --mlu100)
          TARGET_MLU_ARCH="MLU100"
          shift
          ;;
      --mlu220)
          TARGET_MLU_ARCH="MLU220"
          shift
          ;;
      --mlu270)
          TARGET_MLU_ARCH="MLU270"
          shift
          ;;
      --mlu290)
          TARGET_MLU_ARCH="MLU290"
          shift
          ;;
      -d | --debug)
          BUILD_MODE="debug"
          shift
          ;;
      *)
          echo "unknown options ${1}, use -h or --help"
          exit -1;
          ;;
    esac
  done
else
  BUILD_MODE="release"
fi

# Build samples for target mlu arch
pushd ${BUILDDIR}
  rm -rf *
  echo "-- Build in ${BUILD_MODE} mode"
  ${CMAKE} -DCMAKE_BUILD_TYPE=${BUILD_MODE} \
           -DCMAKE_SYSROOT=${SYSROOT} \
           -DTOOLCHAIN_ROOT=${TOOLCHAIN_ROOT} \
           -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
           -DCMAKE_C_COMPILER=${C_COMPILER} \
           -DNEUWARE_HOME=${NEUWARE_HOME} \
           -DTARGET_MLU_ARCH=${TARGET_MLU_ARCH} \
           -DTARGET_CPU_ARCH=${TARGET_CPU_ARCH} \
           ..
  make -j6
  ln -sf ../input_data
popd

【当前已做了哪些信息确认】选填:
例如交叉验证/CPU能运行/调试通过等


【参考配置文档链接】选填


【相关日志文档】选填
见附件


版权所有 © 2024 星空体育 备案/许可证号:京ICP备17003415号-1
关闭