uzh-rpg / rpg_svo_pro_open

GNU General Public License v3.0
1.41k stars 392 forks source link

Cannot complie the fast_neon on Nvidia Xavier #9

Open HilbertXu opened 3 years ago

HilbertXu commented 3 years ago

Dear Sir,

Thanks for open sourcing this amazing SVO2.0!

We try to compile and deploy SVO2.0 on the Nvidia Xavier platform, however, some errors happened when the fast_neon package is being compiled.

The error message shows like: "unrecognized command line option ‘-mfpu=neon’", "unknown value ‘armv7-a’ for -march".

If we delete the "-mfpu=neon" part, the following the whole fast_neon package failed. Message shows like: " #error "This file requires NEON support. Check your compiler flags." This is obvious because we do not add the "-fpu=neon" in the flags.

Could you please give me some advice about how to fix this problem? Thanks you in advance for your kindly help!

Regards, Hilbert Xu

AlexisTM commented 3 years ago

Hi @HilbertXu, I believe those flags are there from the old days of the Odroid XU4 SVO was used on.

If I'm not incorrect, the jetson boards have an arm64v8 architecture, According to this answer, the arm64v8 architecture makes NEON mandatory, thus the -mfpu=neon doesn't have to be maintained on the compiler's side as it has to be present.

So the solution should be to replace armv7 by the correct arm64v8 architecture (check for the correct name) or if building on the board, -march=native could be enough.

mzahana commented 3 years ago

@HilbertXu I am facing the same issue. Have you solved it? I am trying to compile on Jetson Xavier NX dev kit.

mzahana commented 3 years ago

If I remove -mfpu=neon in here, I get the following errors

Errors << fast:make /root/catkin_ws/logs/fast/build.make.000.log               
c++: error: unrecognized command line option '-mmmx'
c++: error: unrecognized command line option '-msse'; did you mean '-fdse'?
c++: error: unrecognized command line option '-msse'; did you mean '-fdse'?
c++: error: unrecognized command line option '-msse2'
c++: error: unrecognized command line option '-msse3'
c++: error: unrecognized command line option '-mssse3'
mzahana commented 3 years ago

I was able to compile fast_neon package by using the test/aarch64-compilation branch.

FPSychotic commented 3 years ago

I was able to compile fast_neon package by using the test/aarch64-compilation branch.

could you please print you commands from the history or anything can help I use the arm4 fast neon you quoted and know compile farest but still crash with the same error

mzahana commented 3 years ago

@FPSychotic Nothing special. Just checkout the branch I mentioned and compile.

FPSychotic commented 3 years ago

@mzahana As I'm not skilled in linux or github what I did is download the zip of that fast_neon branch, substituted the svo with it, and compiled SVO with catkin build, it was able to compile more , but it failed with similar error. is it right what I did? I'm in noetic

Errors << vikit_common:make /home/imother/svo_ws/logs/vikit_common/build.make.000.log c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-mssse3’ c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? c++: error: unrecognized command line option ‘-mssse3’ c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-mssse3’ c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-mssse3’ c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? c++: error: unrecognized command line option ‘-mssse3’ make[2]: *** [CMakeFiles/vikit_common.dir/build.make:104: CMakeFiles/vikit_common.dir/src/performance_monitor.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs.... c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? make[2]: *** [CMakeFiles/vikit_common.dir/build.make:90: CMakeFiles/vikit_common.dir/src/math_utils.cpp.o] Error 1 c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? c++: error: unrecognized command line option ‘-mmmx’ c++: error: unrecognized command line option ‘-msse’; did you mean ‘-fdse’? c++: error: unrecognized command line option ‘-msse2’ c++: error: unrecognized command line option ‘-msse3’ c++: error: unrecognized command line option ‘-mssse3’ c++: error: unrecognized command line option ‘-mno-avx’; did you mean ‘-Wno-abi’? make[2]: *** [CMakeFiles/vikit_common.dir/build.make:76: CMakeFiles/vikit_common.dir/src/homography.cpp.o] Error 1

mzahana commented 3 years ago

@FPSychotic This is not related to fast_neon, but try to replace the content of rpg_svo_pro_open/svo_cmake/cmake/Modules/SvoSetup.cmake by the following

SET(CMAKE_BUILD_TYPE Release) # Release, RelWithDebInfo
#SET(CMAKE_BUILD_TYPE Debug) # Release, RelWithDebInfo
SET(CMAKE_VERBOSE_MAKEFILE OFF)

# user build settings
SET(USE_LOOP_CLOSING TRUE)
SET(USE_GLOBAL_MAP TRUE)

# Set definitions
IF(USE_LOOP_CLOSING)
  ADD_DEFINITIONS(-DSVO_LOOP_CLOSING)
ENDIF()

IF(USE_GLOBAL_MAP)
  ADD_DEFINITIONS(-DSVO_GLOBAL_MAP)
ENDIF()

ADD_DEFINITIONS(-DSVO_USE_ROS)
ADD_DEFINITIONS(-DSVO_USE_OPENGV)
ADD_DEFINITIONS(-DSVO_DEPTHFILTER_IN_REPROJECTOR)

#############################################################################
# Set build flags, set ARM_ARCHITECTURE environment variable on Odroid
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -Werror -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas -Wno-unused-but-set-parameter -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-unused-function")

# IF(DEFINED ENV{ARM_ARCHITECTURE})
#   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=armv7-a")
#   ADD_DEFINITIONS(-DHAVE_FAST_NEON)
# ELSE()
#   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx -msse -msse2 -msse3 -mssse3 -mno-avx")
# ENDIF()

set(ENV{ARM_ARCHITECTURE} aarch64)

IF(DEFINED ENV{ARM_ARCHITECTURE})
    IF("$ENV{ARM_ARCHITECTURE}" STREQUAL "aarch64")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")
        ADD_DEFINITIONS(-DHAVE_FAST_NEON)
    ELSEIF("$ENV{ARM_ARCHITECTURE}" STREQUAL "armv8")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")
        ADD_DEFINITIONS(-DHAVE_FAST_NEON)
    ELSE()
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mfpu=neon -march=armv7-a")
    ENDIF() 
ELSE()
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mmmx -msse -msse -msse2 -msse3 -mssse3 -fomit-frame-pointer")
ENDIF()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-signed-zeros -fno-math-errno -funroll-loops -ffast-math -fno-finite-math-only")
itaouil commented 3 years ago

@mzahana did you manage to run it on the Jetson Xavier already? I would be interested to know what is the CPU load and the frequency of the estimation if you already run it :).

mzahana commented 3 years ago

@itaouil I am currently building a Docker image for it to run on Xavier NX, check jetson_svo_docker repo. It still requires testing.

FPSychotic commented 3 years ago

Thanks you all, I will test it if I can thid weekend and share what I find. Thanks by the effort and your time

On Fri, 5 Nov 2021, 23:41 Mohamed Abdelkader Zahana, < @.***> wrote:

@itaouil https://github.com/itaouil I am currently building a Docker image for it to run on Xavier NX, check jetson_svo_docker https://github.com/mzahana/jetson_svo_docker repo. It still requires testing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/uzh-rpg/rpg_svo_pro_open/issues/9#issuecomment-962280997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AITQOVGHXTCCA5LRMVU7CJ3UKRTTPANCNFSM5ET3ETRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

itaouil commented 3 years ago

@mzahana thanks for sharing repo link.

@FPSychotic let us know. I am very interested :).

fratopa commented 2 years ago

@FPSychotic This is not related to fast_neon, but try to replace the content of rpg_svo_pro_open/svo_cmake/cmake/Modules/SvoSetup.cmake by the following

SET(CMAKE_BUILD_TYPE Release) # Release, RelWithDebInfo
#SET(CMAKE_BUILD_TYPE Debug) # Release, RelWithDebInfo
SET(CMAKE_VERBOSE_MAKEFILE OFF)

# user build settings
SET(USE_LOOP_CLOSING TRUE)
SET(USE_GLOBAL_MAP TRUE)

# Set definitions
IF(USE_LOOP_CLOSING)
  ADD_DEFINITIONS(-DSVO_LOOP_CLOSING)
ENDIF()

IF(USE_GLOBAL_MAP)
  ADD_DEFINITIONS(-DSVO_GLOBAL_MAP)
ENDIF()

ADD_DEFINITIONS(-DSVO_USE_ROS)
ADD_DEFINITIONS(-DSVO_USE_OPENGV)
ADD_DEFINITIONS(-DSVO_DEPTHFILTER_IN_REPROJECTOR)

#############################################################################
# Set build flags, set ARM_ARCHITECTURE environment variable on Odroid
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall -Werror -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas -Wno-unused-but-set-parameter -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wno-unused-function")

# IF(DEFINED ENV{ARM_ARCHITECTURE})
#   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon -march=armv7-a")
#   ADD_DEFINITIONS(-DHAVE_FAST_NEON)
# ELSE()
#   SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx -msse -msse2 -msse3 -mssse3 -mno-avx")
# ENDIF()

set(ENV{ARM_ARCHITECTURE} aarch64)

IF(DEFINED ENV{ARM_ARCHITECTURE})
  IF("$ENV{ARM_ARCHITECTURE}" STREQUAL "aarch64")
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")
      ADD_DEFINITIONS(-DHAVE_FAST_NEON)
  ELSEIF("$ENV{ARM_ARCHITECTURE}" STREQUAL "armv8")
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")
      ADD_DEFINITIONS(-DHAVE_FAST_NEON)
  ELSE()
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mfpu=neon -march=armv7-a")
  ENDIF() 
ELSE()
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -mmmx -msse -msse -msse2 -msse3 -mssse3 -fomit-frame-pointer")
ENDIF()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-signed-zeros -fno-math-errno -funroll-loops -ffast-math -fno-finite-math-only")

thanks, solved the vikit_common problem

yanyan-li commented 2 years ago

I was able to compile fast_neon package by using the test/aarch64-compilation branch.

Thanks for the advice. It works on my chips. Taking the proposed fast_neon folder to take place of the original one if you want to try it on ARM64 chips.

leonpano2006 commented 10 months ago

Hi @HilbertXu, I believe those flags are there from the old days of the Odroid XU4 SVO was used on.

If I'm not incorrect, the jetson boards have an arm64v8 architecture, According to this answer, the arm64v8 architecture makes NEON mandatory, thus the -mfpu=neon doesn't have to be maintained on the compiler's side as it has to be present.

So the solution should be to replace armv7 by the correct arm64v8 architecture (check for the correct name) or if building on the board, -march=native could be enough.

-march=native doesn't work as expected on xavier nx/agx It still give generic for many things like -mtune -mcpu .....

Have to manually specify optimization