cbfinn / gps

Guided Policy Search
http://rll.berkeley.edu/gps/
Other
594 stars 239 forks source link

Compiling in Mac with Mujoco #28

Closed mjm522 closed 8 years ago

mjm522 commented 8 years ago

I was successfully able to run ./compile_proto.sh, It did created all necessary directories.

After to install the integration with MuJoCo 1.31, I have kept the mjpro directory inside 3rd party and put the key inside it: This is my log file. CMakeOutput .txt

, I tried the following and gets following log for cmake and make -j.

$ cmake ../src/3rdparty
-- The C compiler identification is AppleClang 7.3.0.7030031
-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7") 
CMake Error at /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/FindPythonLibs.cmake:64 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  Boost.NumPy/CMakeLists.txt:14 (find_package)

-- Found PythonInterp: python (found version "2.7.11") 
-- Found NumPy: version "1.11.0" /usr/local/lib/python2.7/site-packages/numpy/core/include
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   python
-- found boost:
INCLUDE: /usr/local/include
LIB: /usr/local/lib/libboost_python-mt.dylib
osg includes: 
-- Configuring incomplete, errors occurred!
See also "/Users/michaelmathew/gps/build/CMakeFiles/CMakeOutput.log".
Michaels-MacBook-Pro:build michaelmathew$ make -j
make: *** No targets specified and no makefile found.  Stop.

Is there anything else that needs to done while installing on mac? I am using OSX El Capitan

cbfinn commented 8 years ago

I would recommend trying to upgrade your cmake version. (e.g. found this on a quick google search: https://github.com/openMVG/openMVG/issues/348)

Chelesa

On Fri, Jun 10, 2016 at 7:56 PM, mjm522 notifications@github.com wrote:

I was successfully able to run ./compile_proto.sh, It did created all necessary directories.

After to install the integration with MuJoCo, I tried the following and gets following log for cmake and make -j.

$ cmake ../src/3rdparty -- The C compiler identification is AppleClang 7.3.0.7030031 -- The CXX compiler identification is AppleClang 7.3.0.7030031 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Setting build type to 'Release' as none was specified. -- Boost version: 1.60.0 -- Found the following Boost libraries: -- python -- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.10", minimum required is "2.7") CMake Error at /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/FindPythonLibs.cmake:64 (get_filename_component): get_filename_component called with incorrect number of arguments Call Stack (most recent call first): Boost.NumPy/CMakeLists.txt:14 (find_package)

-- Found PythonInterp: python (found version "2.7.11") -- Found NumPy: version "1.11.0" /usr/local/lib/python2.7/site-packages/numpy/core/include -- Boost version: 1.60.0 -- Found the following Boost libraries: -- python -- found boost: INCLUDE: /usr/local/include LIB: /usr/local/lib/libboost_python-mt.dylib osg includes: -- Configuring incomplete, errors occurred! See also "/Users/michaelmathew/gps/build/CMakeFiles/CMakeOutput.log". Michaels-MacBook-Pro:build michaelmathew$ make -j make: *\ No targets specified and no makefile found. Stop.

Is there anything else that needs to done while installing on mac? I am using OSX El Capitan

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cbfinn/gps/issues/28, or mute the thread https://github.com/notifications/unsubscribe/ABMlAYGOn2PfshdOFr_z6Td2J2Sv9QC1ks5qKiPagaJpZM4IzdIW .

mjm522 commented 8 years ago

I am already using Cmake 3.5.2..

cbfinn commented 8 years ago

@zhangmarvin , @svlevine Do you know who has experience compiling mujoco on mac?

svlevine commented 8 years ago

Compiling MuJoCo, or compiling mjcpy? MuJoCo is closed source, so we do not compile it. I believe there are mac binaries (you can check on the Roboti website), and then we have to figure out how to compile mjcpy for Mac, which I think shouldn't be too hard.

The error above is

CMake Error at /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/FindPythonLibs.cmake:64 (get_filename_component): get_filename_component called with incorrect number of arguments

It doesn't look like this has anything to do with us. Probably a mismatch between the cmake version and the FindPythonLibs.cmake module.

mjm522 commented 8 years ago

I solved this issue by downgrading to Cmake 3.3.2 and then rebuilding. However now I have a new error. when I try to run the example python python/gps/gps_main.py mjc_example It says: No module named mjcpy

cbfinn commented 8 years ago

That error usually means that your python path isn't set up properly. Make sure that mjcpy is on your python path and ld library path, as explained in the set-up instructions.

Also, .bashrc files aren't always executed on start-up for macs, so you may want to source it in your .bash_profile.

mjm522 commented 8 years ago

I have edited the .bash_profile. and it does give out the path on echoing. I have doubt:

The setup says to add

export DLD_LIBRARY_PATH=$DLD_LIBRARY_PATH:/path/to/gps/build/lib
export PYTHONPATH=$PYTHONPATH:/path/to/gps/build/lib

The make -jhas produced only one file in the above path. libboost_numpy.dylib There are no files by the name mjcpy in the above path or is it within the above library?. How many files do the make -j generate? I didn't get a single error while doing cmake or make!!!

With the above path given a python terminal also fails to find the file mjcpy.

Can you please suggest what might have went wrong other than the path problem.?

I have another doubt(suggestion) as well. The Cmakelist.txt inside /gps_path/src/mjcpy2/ the final line is

target_link_libraries(mjcpy "${CMAKE_SOURCE_DIR}/mjpro/libmujoco.so" ${OSG_LIBRARIES} boost_numpy)

But .so is a runtime library for linux. In mac it should be a .dylib file. So I edited the above line to be

target_link_libraries(mjcpy "${CMAKE_SOURCE_DIR}/mjpro131/bin/libmujoco131.dylib" ${OSG_LIBRARIES} boost_numpy) So I guess your Cmake file should be added with the above line; though you have an if-endif instruction for detecting Apple inside Cmakelist.txt, you have only specified a single type of dynamic library integration which may not work in mac.

mjm522 commented 8 years ago

I saw there were some changes . I too edited the files as mentioned in the post. And finally I successfully compiled mjcpy.so!!!

That led to the new error in python terminal:

>>> import mjcpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/michaelmathew/gps/build/lib/mjcpy.so, 2): Library not loaded: @executable_path/libmujoco131.dylib
  Referenced from: /Users/michaelmathew/gps/build/lib/mjcpy.so
  Reason: image not found

I solved it by providing a sym link to the folder to /usr/lib

But now error is not there, but the moment I import, python terminal quits with following error.

"Python quit unexpectedly" with Segmentation fault: 11

Could you please suggest anything.. if it rings a bell? I almost did it.. but.... -_-

Note: Google search shows that this error is persistent with OSx python. But In all these years, I have never faced it with any of my python codes.

mjm522 commented 8 years ago

Could you please tell me on which version of python you got it working?

cbfinn commented 8 years ago

We assume python 2.7, as mentioned on the docs: http://rll.berkeley.edu/gps/

eaa3 commented 8 years ago

There appears to be a problem with line 64 in the file /usr/local/Cellar/cmake/3.5.2/share/cmake/Modules/FindPythonLibs.cmake. I have temporarily commented this line in order to build gps on OSX Mavericks. After that, it generates fine with cmake 3.5.1. My guess is that there was a change in the behaviour of the function get_filename_component on more recent versions of cmake that made the statement in line 64 syntactically incorrect.

Editing to mention that cmake 3.5.1 presented similar issue

mjm522 commented 8 years ago

I finally compiled everything and it works fine now.

Here are a set of instructions to follow to install gps on Mac. It is tested on OSX El-Capitan and OSX Maverics :)

cbfinn commented 8 years ago

Great, thanks!

cbfinn commented 8 years ago

Can you make a pull request that adds a link to your instructions to the gps docs?

mjm522 commented 8 years ago

I put them up as a text file. and Submitted :)

cbfinn commented 8 years ago

I don't see the pull request...

mjm522 commented 8 years ago

Could you please check now?

robotsorcerer commented 7 years ago

Did you guys merge the pull request? I spent a number of hours trying to get this fixed.

jangirrishabh commented 6 years ago

@mjm522 @cbfinn I found an easier solution, just comment out Line number 14 in gps/src/3rdparty/Boost.NumPy/CMakeLists.txt Where it is trying to look for PythonLibs 2.7 REQUIRED, because the requirement is already satisfied and thus conflicting with 3rdparty/CMakeLists.txt

I am in a Anaconda virtual environment on a Linux GPU machine, so my guess is that there was a conflict between the root python libs and the conda python libs

screenshot from 2018-02-06 12 23 39