BerkeleyAutomation / dex-net

Repository for reading the Dex-Net 2.0 HDF5 database of 3D objects, parallel-jaw grasps, and robust grasp metrics
https://berkeleyautomation.github.io/dex-net/code.html
Other
296 stars 97 forks source link

AttributeError: 'module' object has no attribute 'render_mesh' #36

Open JoonHyup opened 5 years ago

JoonHyup commented 5 years ago

Hello. After I install the dex-net. I try the test as follow:

python2 setup.py test

But I got an error as follow:

ERROR

====================================================================== ERROR: test_new_database_and_graspable (test.database_test.Hdf5DatabaseTest)

Traceback (most recent call last): File "/home/bjh/catkin_ws/src/dex-net-master/test/database_test.py", line 168, in test_new_database_and_graspable stable_pose) File "/usr/local/lib/python2.7/dist-packages/meshpy/mesh_renderer.py", line 716, in wrapped_images_viewsphere return self.wrapped_images(mesh, vs_disc.object_to_camera_poses(), render_mode, stable_pose=stable_pose, mat_props=mat_props, light_props=light_props) File "/usr/local/lib/python2.7/dist-packages/meshpy/mesh_renderer.py", line 587, in wrapped_images debug=debug) File "/usr/local/lib/python2.7/dist-packages/meshpy/mesh_renderer.py", line 489, in images c, d = meshrender.render_mesh([P], AttributeError: 'module' object has no attribute 'render_mesh'


Ran 15 tests in 100.610s

FAILED (errors=1) Test failed: error: Test failed:

I tried to solve the problem but nothing I can do. Please help me. Thank you

EvanLavizadeh commented 5 years ago

I get the same error. Can you please post the entire output from the terminal after executing the test command?

jeffmahler commented 5 years ago

This is a symptom of meshrender failing to build and install properly. Can you run:

cd /path/to/meshpy
sh install_meshrender.sh

And post the output? I believe you have error messages somewhere.

EvanLavizadeh commented 5 years ago

@jeffmahler When running sh install_meshrender.sh:

-- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /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: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found PythonInterp: /usr/bin/python (found version "2.7.12") -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.12", minimum required is "2.7") -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so
-- Boost version: 1.58.0 -- Found the following Boost libraries: -- python -- Configuring done -- Generating done -- Build files have been written to: /home/evan/dex-net-python/dex-net/deps/meshpy/build /usr/bin/cmake -H/home/evan/dex-net-python/dex-net/deps/meshpy -B/home/evan/dex-net-python/dex-net/deps/meshpy/build --check-build-system CMakeFiles/Makefile.cmake 0 /usr/bin/cmake -E cmake_progress_start /home/evan/dex-net-python/dex-net/deps/meshpy/build/CMakeFiles /home/evan/dex-net-python/dex-net/deps/meshpy/build/CMakeFiles/progress.marks make -f CMakeFiles/Makefile2 all make[1]: Entering directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' make -f meshpy/CMakeFiles/meshrender.dir/build.make meshpy/CMakeFiles/meshrender.dir/depend make[2]: Entering directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' cd /home/evan/dex-net-python/dex-net/deps/meshpy/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/evan/dex-net-python/dex-net/deps/meshpy /home/evan/dex-net-python/dex-net/deps/meshpy/meshpy /home/evan/dex-net-python/dex-net/deps/meshpy/build /home/evan/dex-net-python/dex-net/deps/meshpy/build/meshpy /home/evan/dex-net-python/dex-net/deps/meshpy/build/meshpy/CMakeFiles/meshrender.dir/DependInfo.cmake --color= Scanning dependencies of target meshrender make[2]: Leaving directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' make -f meshpy/CMakeFiles/meshrender.dir/build.make meshpy/CMakeFiles/meshrender.dir/build make[2]: Entering directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' [ 50%] Building CXX object meshpy/CMakeFiles/meshrender.dir/meshrender.cpp.o cd /home/evan/dex-net-python/dex-net/deps/meshpy/build/meshpy && /usr/bin/c++ -Dmeshrender_EXPORTS -I/usr/include/python2.7 -fPIC -o CMakeFiles/meshrender.dir/meshrender.cpp.o -c /home/evan/dex-net-python/dex-net/deps/meshpy/meshpy/meshrender.cpp [100%] Linking CXX shared module meshrender.so cd /home/evan/dex-net-python/dex-net/deps/meshpy/build/meshpy && /usr/bin/cmake -E cmake_link_script CMakeFiles/meshrender.dir/link.txt --verbose=1 /usr/bin/c++ -fPIC -shared -o meshrender.so CMakeFiles/meshrender.dir/meshrender.cpp.o -lboost_python -lpython2.7 -lboost_numpy -lglut -lXmu -lXi -lOSMesa make[2]: Leaving directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' [100%] Built target meshrender make[1]: Leaving directory '/home/evan/dex-net-python/dex-net/deps/meshpy/build' /usr/bin/cmake -E cmake_progress_start /home/evan/dex-net-python/dex-net/deps/meshpy/build/CMakeFiles 0

jeffmahler commented 5 years ago

Interesting that actually looks correct. Do you also have the other version of meshrender installed?: https://github.com/BerkeleyAutomation/meshrender

Perhaps there is a name conflict.

EvanLavizadeh commented 5 years ago

@jeffmahler I don't think so. I haven't separately installed meshrender outside dex-net. Is there a way I can check to be sure?

jeffmahler commented 5 years ago

You could try opening a Python interpreter and then examining the output of:

import meshpy
print(meshpy.__file__)

Then see if there is a file meshrender.so in that directory

EvanLavizadeh commented 5 years ago

@jeffmahler When trying to import meshpy, i get:

Unable to import meshrender shared library! Rendering will not work. Likely due to missing Boost.Numpy Boost.Numpy can be installed following the instructions in https://github.com/ndarray/Boost.NumPy WARNING:root:autolab_core not installed as catkin package, RigidTransform ros methods will be unavailable /usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.') WARNING:root:autolab_perception is not installed as a catkin package - ROS msg conversions will not be available for image wrappers WARNING:root:Unable to import CNN modules! Likely due to missing tensorflow. WARNING:root:TensorFlow can be installed following the instructions in https://www.tensorflow.org/get_started/os_setup WARNING:root:Unable to import pylibfreenect2. Python-only Kinect driver may not work properly. WARNING:root:Failed to import ROS in Kinect2_sensor.py. Kinect will not be able to be used in bridged mode WARNING:root:Unable to import openni2 driver. Python-only Primesense driver may not work properly WARNING:root:primesense_sensor.py not installed as catkin package. ROS functionality not available. WARNING:root:Unable to import pyrealsense2. WARNING:root:realsense_sensor.py not installed as catkin package. ROS functionality not available. WARNING:root:Failed to import ROS in ensenso_sensor.py. ROS functionality not available WARNING:root:Failed to import ROS in phoxi_sensor.py. PhoXiSensor functionality unavailable.

I don't know why boost.numpy couldn't install, but I'm having other issues installing boost.numpy separately. That might be something I should solve on my own?

JoonHyup commented 5 years ago

@jeffmahler

Hello when I type:

import meshpy print(meshpy.file)

I got the path of the meshrender.so as follow:

'>>> import meshpy /home/bjh/.local/lib/python2.7/site-packages/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown. warnings.warn(warning, RequestsDependencyWarning) WARNING:root:Unable to import pylibfreenect2. Python-only Kinect driver may not work properly. WARNING:root:Unable to import openni2 driver. Python-only Primesense driver may not work properly WARNING:trimesh:No FCL -- collision checking will not work '>>> print(meshpy.file) /usr/local/lib/python2.7/dist-packages/meshpy/init.pyc

what should I do next??

SilviaSapora commented 5 years ago

I have solved this problem. There are multiple issues with this. First of all, as Jeff mentioned, there are 2 modules with the same name(meshrender) one is used in visualization3d and is the one you install by:

pip install meshrender

And another one is the one you get by running the install_meshrender.sh script. To solve this problem I had to rename the meshpy's meshrender to be called meshrender2. I don't know if you had this problem. Secondly, I you have to make sure meshpy's meshrender is building and linking correctly, and it is included to the python path. I also see you seem to have problems with Boost.NumPy. Is there a directory called Boost.Numpy under "dex-net/deps"? If not perform the following:

sudo apt -y install  libboost1.62-dev  libpython2.7-dev libboost-python-dev
git clone https://github.com/ndarray/Boost.NumPy
cd Boost.Numpy
mkdir build
cd build
cmake ..
make 
sudo make install

Take note of where Boost.NumPy is installed.

If you have linking problems with meshrender, try not deleting the build directory and linking the file again(changing meshrender2 to meshrender if that is what you want to name it). From the meshpy directory:

cd build
sudo /usr/bin/c++ -fPIC   -shared  -o meshrender2.so meshpy/CMakeFiles/meshrender2.dir/meshrender2.cpp.o -Wl,--whole-archive -L/usr/local/lib64/ -lboost_numpy -Wl,--no-whole-archive -lboost_python -lpython2.7 -lglut -lXmu -lXi -lOSMesa

Some things are probably overkill but this worked for me, so I'm just copy-pasting as it was. Also for me "-L/usr/local/lib64/" was were Boost.NumPy was installed. Replace it with whatever your directory is.

Also, when you are calling your scripts, make sure the path to Boost.NumPy is included in your python path.

Sorry if the instructions are not very clear but I've spent 3h on this and I've forgotten half the things I've done/tried. Every time I solved one problem I was getting another and I really can't remember what I did to solve each one of them. If you still have problems I can try and give you more details.

I hope this is somewhat helpful.

EvanLavizadeh commented 5 years ago

Thanks @SilviaSapora I had a similar situation where I tried a bunch of stuff in rapid succession and it works but I didn't do it methodically so now I don't remember exactly which steps fixed which symptoms.

One thing I did that seemed to fix the issue was to specify the path for Boost in the lib path by these steps:

  1. Create new .conf file in directory /etc/ld.so.conf.d (filename doesn't matter. I called mine local.conf) (You will need root permissions to do this)
  2. Add these three lines (I don't know if all 3 are necessary): /usr/local/lib /usr/local/lib64 /usr/local/include/boost

I think this achieves the same result.

mariabauza commented 5 years ago

I had the same problem and this is how I solved it:

  1. After installing Boost.Numpy, the file "libboost_numpy.so " went into the folder: /usr/local/lib64
  2. If you do ldd meshrender.so you get: libboost_numpy.so => /usr/local/lib/libboost_numpy.so
  3. I moved the file libboost_numpy.so to the folder where it is expected to be: /usr/local/lib

Finally, because there are 2 meshrenders, I actually called meshrender.so as meshrender2.so and import that one (import meshrender2 ) as @SilviaSapora mentioned. Hope it helps!

yruoxi commented 4 years ago

I am still having this issue. First of all, catkin_make and build was successful, no error message here. Boost.Numpy is there.

dex-net INFO Rendering images for object pineapple in pose_0 Traceback (most recent call last): File "generate_gqcnn_dataset.py", line 611, in config) File "generate_gqcnn_dataset.py", line 409, in generate_gqcnn_dataset render_samples = urv.rvs(size=image_samples_per_stable_pose) File "/home/ryu/catkin_ws/src/autolab_core/autolab_core/random_variables.py", line 81, in rvs return self.sample(size=size) File "/usr/local/lib/python2.7/dist-packages/meshpy/random_variables.py", line 498, in sample render_mode, stable_pose=self.stable_pose) File "/usr/local/lib/python2.7/dist-packages/meshpy/mesh_renderer.py", line 587, in wrapped_images debug=debug) File "/usr/local/lib/python2.7/dist-packages/meshpy/mesh_renderer.py", line 489, in images c, d = meshrender.render_mesh([P], AttributeError: 'module' object has no attribute 'render_mesh'

Here is the exact error message, I am able to import either meshrender and meshpy in python.

import meshrender WARNING:root:Failed to import ROS in Kinect2_sensor.py. Kinect will not be able to be used in bridged mode WARNING:root:Unable to import openni2 driver. Python-only Primesense driver may not work properly WARNING:root:Failed to import ROS in ensenso_sensor.py. ROS functionality not available WARNING:root:Failed to import ROS in phoxi_sensor.py. PhoXiSensor functionality unavailable.

I tried all above methods, including adding ld_library_path, moving libboost.so, changing meshrender to meshrender2 but unable to import meshrender2

import meshrender2 Traceback (most recent call last): File "", line 1, in ImportError: No module named meshrender2

In my attempts I attempted with and without the following changes, in different combinations. I did change the meshrender.cpp to meshrender2.cpp then changing the makefile to meshrender2.cpp, meshrender.so to meshrender2.so also changed the import meshrender to import meshrender2 as meshrender

PYTHON_ADD_MODULE(meshrender2 meshrender2.cpp) INSTALL(TARGETS meshrender2 DESTINATION meshpy)

Also changed the last few lines in the meshrender2.cpp in that attempt into:

BOOST_PYTHON_MODULE(meshrender2) { Py_Initialize(); boost::numpy::initialize(); boost::python::numeric::array::set_module_and_type("numpy", "ndarray");

def("mul_array", &mul_array); def("render_mesh", &render_mesh); }

followed by a catkin_make clean and catkin_make, source devel/setup.bash still cannot find meshrender2, the error still occurs after the above suggested method, cannot find attribute render_mesh

yruoxi commented 4 years ago

Solved, python was looking at the meshpy in dist_packages folder so it is most effective to move meshrender.cpp into the lib/python2.7/dist_packages/meshpy folder, then it will be found

zch-cpu commented 3 years ago

Thanks @SilviaSapora I had a similar situation where I tried a bunch of stuff in rapid succession and it works but I didn't do it methodically so now I don't remember exactly which steps fixed which symptoms.

One thing I did that seemed to fix the issue was to specify the path for Boost in the lib path by these steps:

  1. Create new .conf file in directory /etc/ld.so.conf.d (filename doesn't matter. I called mine local.conf) (You will need root permissions to do this)
  2. Add these three lines (I don't know if all 3 are necessary): /usr/local/lib /usr/local/lib64 /usr/local/include/boost

I think this achieves the same result.

Thanks, bro. It works for me.