xbpeng / DeepMimic

Motion imitation with deep reinforcement learning.
https://xbpeng.github.io/projects/DeepMimic/index.html
MIT License
2.31k stars 488 forks source link

Build error on Ubuntu 18.04 #54

Closed raffaello-camoriano closed 5 years ago

raffaello-camoriano commented 5 years ago

Hello, thank you very much for making your code available.

I've read the DeepMimic paper and found it very interesting for my research. I would like to try the experiments myself.

After following the instructions I am currently stuck with the following build error and would like to ask for help. It may well be something trivial.

Thank you in advance.

Host system info

C++

Miscellanea

Python3

Source directories settings

As specified in https://github.com/xbpeng/DeepMimic#linux by the author of DeepMimic, i specified the following installation directories before running make python:

Error

kammo@kammo-XPS-15-9560:~/repos/DeepMimic/DeepMimicCore$ make python
clang++ -c -g -std=c++11 -O3 -Wall -fPIC  -I./ -I../../eigen-git-mirror -I../../bullet3/src -o objs/Main.o Main.cpp
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1056:23: error: 
      redefinition of '_mm_castpd_ps'
static inline __m128  _mm_castpd_ps   (__m128d x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4833:1: note: 
      previous definition is here
_mm_castpd_ps(__m128d __a)
^
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1057:23: error: 
      redefinition of '_mm_castpd_si128'
static inline __m128i _mm_castpd_si128(__m128d x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4850:1: note: 
      previous definition is here
_mm_castpd_si128(__m128d __a)
^
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1058:23: error: 
      redefinition of '_mm_castps_pd'
static inline __m128d _mm_castps_pd   (__m128  x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4867:1: note: 
      previous definition is here
_mm_castps_pd(__m128 __a)
^
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1059:23: error: 
      redefinition of '_mm_castps_si128'
static inline __m128i _mm_castps_si128(__m128  x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4884:1: note: 
      previous definition is here
_mm_castps_si128(__m128 __a)
^
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1060:23: error: 
      redefinition of '_mm_castsi128_ps'
static inline __m128  _mm_castsi128_ps(__m128i x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4901:1: note: 
      previous definition is here
_mm_castsi128_ps(__m128i __a)
^
In file included from Main.cpp:3:
In file included from ./DeepMimicCore.h:3:
In file included from ./util/ArgParser.h:6:
In file included from ./util/MathUtil.h:5:
In file included from ../../eigen-git-mirror/Eigen/Dense:1:
In file included from ../../eigen-git-mirror/Eigen/Core:177:
../../eigen-git-mirror/Eigen/src/Core/arch/SSE/PacketMath.h:1061:23: error: 
      redefinition of '_mm_castsi128_pd'
static inline __m128d _mm_castsi128_pd(__m128i x) { return ...
                      ^
/usr/include/clang/6.0.0/include/emmintrin.h:4918:1: note: 
      previous definition is here
_mm_castsi128_pd(__m128i __a)
^
In file included from Main.cpp:7:
In file included from ./render/DrawUtil.h:6:
In file included from ./render/DrawMesh.h:21:
In file included from ./render/VertexBuffer.h:4:
./render/RenderState.h:87:44: warning: cast to 'void *' from
      smaller integer type 'unsigned int'
      [-Wint-to-void-pointer-cast]
                              mDataStride, (GLvoid *) mDataOffset);
                                           ^
In file included from Main.cpp:7:
In file included from ./render/DrawUtil.h:6:
In file included from ./render/DrawMesh.h:21:
./render/VertexBuffer.h:20:32: warning: field 'mRenderState' will
      be initialized after field 'mLocalData' [-Wreorder]
        cVertexBuffer():mRenderID(0), mRenderState(NULL), m...
                                      ^
./render/VertexBuffer.h:20:52: warning: field 'mLocalData' will be
      initialized after field 'mAttrInfo' [-Wreorder]
        cVertexBuffer():mRenderID(0), mRenderState(NULL), mLocalDat...
                                                          ^
./render/VertexBuffer.h:21:15: warning: field 'mAttrInfo' will be
      initialized after field 'mNumAttr' [-Wreorder]
              mAttrInfo(NULL), mNumAttr(0), mSize(0)
              ^
./render/VertexBuffer.h:21:32: warning: field 'mNumAttr' will be
      initialized after field 'mSize' [-Wreorder]
              mAttrInfo(NULL), mNumAttr(0), mSize(0)
                               ^
./render/VertexBuffer.h:23:77: warning: field 'mRenderState' will
      be initialized after field 'mLocalData' [-Wreorder]
  ...bufferID, cRenderState &r_state):mRenderID(bufferID), mRend...
                                                           ^
./render/VertexBuffer.h:23:101: warning: field 'mLocalData' will be
      initialized after field 'mAttrInfo' [-Wreorder]
  ...&r_state):mRenderID(bufferID), mRenderState(&r_state), mLoc...
                                                            ^
./render/VertexBuffer.h:24:40: warning: field 'mAttrInfo' will be
      initialized after field 'mNumAttr' [-Wreorder]
                                       mAttrInfo(NULL), mNu...
                                       ^
./render/VertexBuffer.h:24:57: warning: field 'mNumAttr' will be
      initialized after field 'mSize' [-Wreorder]
                                       mAttrInfo(NULL), mNu...
                                                        ^
./render/VertexBuffer.h:26:69: warning: field 'mRenderState' will
      be initialized after field 'mNumAttr' [-Wreorder]
  ...cVertexBuffer &old): mRenderID(old.mRenderID), mRenderState...
                                                    ^
./render/VertexBuffer.h:26:101: warning: field 'mNumAttr' will be
      initialized after field 'mSize' [-Wreorder]
  ...mRenderState(old.mRenderState), mNumAttr(old.mNumAttr),
                                     ^
In file included from Main.cpp:7:
In file included from ./render/DrawUtil.h:6:
In file included from ./render/DrawMesh.h:22:
./render/IBuffer.h:32:28: warning: field 'mRenderState' will be
      initialized after field 'mLocalData' [-Wreorder]
        cIBuffer(): mRenderID(0), mRenderState(NULL), mLoca...
                                  ^
./render/IBuffer.h:32:48: warning: field 'mLocalData' will be
      initialized after field 'mElemSize' [-Wreorder]
        cIBuffer(): mRenderID(0), mRenderState(NULL), mLoca...
                                                      ^
./render/IBuffer.h:32:66: warning: field 'mElemSize' will be
      initialized after field 'mSize' [-Wreorder]
  ...mRenderID(0), mRenderState(NULL), mLocalData(NULL), mElemSi...
                                                         ^
./render/IBuffer.h:34:73: warning: field 'mRenderState' will be
      initialized after field 'mLocalData' [-Wreorder]
  ...bufferID, cRenderState &r_state): mRenderID(bufferID), mRen...
                                                            ^
./render/IBuffer.h:34:97: warning: field 'mLocalData' will be
      initialized after field 'mElemSize' [-Wreorder]
  ...&r_state): mRenderID(bufferID), mRenderState(&r_state), mLo...
                                                             ^
./render/IBuffer.h:34:115: warning: field 'mElemSize' will be
      initialized after field 'mSize' [-Wreorder]
  ...mRenderState(&r_state), mLocalData(NULL), mElemSize(0), mSi...
                                               ^
Main.cpp:67:10: warning: unused variable 'reward_min'
      [-Wunused-variable]
                double reward_min = gCore->GetRewardMin(id);
                       ^
Main.cpp:48:7: warning: unused variable 'action_space'
      [-Wunused-variable]
                int action_space = gCore->GetActionSpace(id);
                    ^
Main.cpp:51:7: warning: unused variable 'action_size'
      [-Wunused-variable]
                int action_size = gCore->GetActionSize(id);
                    ^
Main.cpp:52:7: warning: unused variable 'num_actions'
      [-Wunused-variable]
                int num_actions = gCore->GetNumActions(id);
                    ^
Main.cpp:69:10: warning: unused variable 'reward_fail'
      [-Wunused-variable]
                double reward_fail = gCore->GetRewardFail(id);
                       ^
Main.cpp:68:10: warning: unused variable 'reward_max'
      [-Wunused-variable]
                double reward_max = gCore->GetRewardMax(id);
                       ^
Main.cpp:70:10: warning: unused variable 'reward_succ'
      [-Wunused-variable]
                double reward_succ = gCore->GetRewardSucc(id);
                       ^
Main.cpp:49:7: warning: unused variable 'state_size'
      [-Wunused-variable]
                int state_size = gCore->GetStateSize(id);
                    ^
Main.cpp:50:7: warning: unused variable 'goal_size'
      [-Wunused-variable]
                int goal_size = gCore->GetGoalSize(id);
                    ^
Main.cpp:111:12: warning: unused variable 'r' [-Wunused-variable]
                                double r = gCore->CalcReward(id);
                                       ^
27 warnings and 6 errors generated.
Makefile:50: recipe for target 'objs/Main.o' failed
make: *** [objs/Main.o] Error 1
raffaello-camoriano commented 5 years ago

The functions which get multiple definition errors are the following casting ones (static inline functions):

_mm_castpd_ps⚠ | x86-64 and sse2Casts a 128-bit floating-point vector of [2 x double] into a 128-bit floating-point vector of [4 x float].
-- | --
_mm_castpd_si128⚠ | x86-64 and sse2Casts a 128-bit floating-point vector of [2 x double] into a 128-bit integer vector.
_mm_castps_pd⚠ | x86-64 and sse2Casts a 128-bit floating-point vector of [4 x float] into a 128-bit floating-point vector of [2 x double].
_mm_castps_si128⚠ | x86-64 and sse2Casts a 128-bit floating-point vector of [4 x float] into a 128-bit integer vector.
_mm_castsi128_pd⚠ | x86-64 and sse2Casts a 128-bit integer vector into a 128-bit floating-point vector of [2 x double].
_mm_castsi128_ps⚠ | x86-64 and sse2Casts a 128-bit integer vector into a 128-bit floating-point vector of [4 x float].

Apparently they are doubly defined in h-files in both the following Eigen installation and Clang directories:

Note: the definitions are different. e.g., for _mm_castpd_ps the definition of the function in the Clang directory is:

/// \brief Casts a 128-bit floating-point vector of [2 x double] into a 128-bit
///    floating-point vector of [4 x float].
///
/// \headerfile <x86intrin.h>
///
/// This intrinsic has no corresponding instruction.
///
/// \param __a
///    A 128-bit floating-point vector of [2 x double].
/// \returns A 128-bit floating-point vector of [4 x float] containing the same
///    bitwise pattern as the parameter.
static __inline__ __m128 __DEFAULT_FN_ATTRS
_mm_castpd_ps(__m128d __a)
{
  return (__m128)__a;
}

On the other hand, the definitions in the Eigen directory are:

#if EIGEN_COMP_PGI < 1900
// PGI++ does not define the following intrinsics in C++ mode.
static inline __m128  _mm_castpd_ps   (__m128d x) { return reinterpret_cast<__m128&>(x);  }
static inline __m128i _mm_castpd_si128(__m128d x) { return reinterpret_cast<__m128i&>(x); }
static inline __m128d _mm_castps_pd   (__m128  x) { return reinterpret_cast<__m128d&>(x); }
static inline __m128i _mm_castps_si128(__m128  x) { return reinterpret_cast<__m128i&>(x); }
static inline __m128  _mm_castsi128_ps(__m128i x) { return reinterpret_cast<__m128&>(x);  }
static inline __m128d _mm_castsi128_pd(__m128i x) { return reinterpret_cast<__m128d&>(x); }
#endif
raffaello-camoriano commented 5 years ago

We discovered there was a problem with the version of Eigen3 I had installed via https://github.com/eigenteam/eigen-git-mirror, corresponding to this commit from 17 days ago: https://github.com/eigenteam/eigen-git-mirror/tree/08eb1921b89b1d826f8b699bc2e54d68451b3751

This version had an issue with the EIGEN_COMP_PGI environment variable, which was fixed (https://bitbucket.org/eigen/eigen/commits/bf5052da0fca417007983107ba836d1d1ae6ae0a) after a few days.

We fixed the problem using the default Ubuntu 18.04 version of Eigen (3.3.4) instead (or also the most recent version as of today: 7805e962d9293578332e8b54f13f4a65a5faee11), by running sudo apt-get install libeigen3-dev and setting EIGEN_DIR = /usr/include/eigen3 in the DeepMimicCore Makefile

xbpeng commented 5 years ago

cool, thanks for the note!

raffaello-camoriano commented 5 years ago

You're welcome!