microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.18k stars 443 forks source link

tensorflow.python.framework.errors_impl.NotFoundError: ./renderer/rasterize_triangles_kernel.so: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs #157

Open DoubleYanLee opened 3 years ago

DoubleYanLee commented 3 years ago

when I run "python demo.py", I get this error, the detail message is:

Traceback (most recent call last):
  File "demo.py", line 12, in <module>
    from face_decoder import Face3D
  File "/home/ly/yanyan/Deep3DFaceReconstruction/face_decoder.py", line 10, in <module>
    from renderer import mesh_renderer
  File "/home/ly/yanyan/Deep3DFaceReconstruction/renderer/mesh_renderer.py", line 25, in <module>
    from renderer import rasterize_triangles
  File "/home/ly/yanyan/Deep3DFaceReconstruction/renderer/rasterize_triangles.py", line 30, in <module>
    rasterize_triangles_module = tf.load_op_library('./renderer/rasterize_triangles_kernel.so')
  File "/home/ly/.conda/envs/deep3d/lib/python3.6/site-packages/tensorflow/python/framework/load_library.py", line 60, in load_op_library
    lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: ./renderer/rasterize_triangles_kernel.so: undefined symbol: _ZN10tensorflow12OpDefBuilder4AttrESs

I suspect the problem is about the file " rasterize_triangles_kernel.so ". I just download the pre-compiled binary file (rasterize_triangles_kernel.so), but I'm sure my tensorflow version is 1.12.

Your help would be highly appreciated.

YuDeng commented 3 years ago

Hi, the pre-compiled binary file only works if you install tensorflow 1.12 via pip install and use cuda 9.0. If you install tensorflow via conda with other version of cudatoolkit, you have to compile tf_mesh_renderer from source using bazel.

rakaar commented 3 years ago

image I have tensorflow v=2.5.0, and cuda 9.0 But still this error persists. Please let me know, what else can go wrong!

YuDeng commented 3 years ago

image I have tensorflow v=2.5.0, and cuda 9.0 But still this error persists. Please let me know, what else can go wrong!

Hi, I'm not sure if tensorflow version >= 2.0 can work.

rakaar commented 3 years ago

@YuDeng Thank you for the response. I downgraded to the TensorFlow version=1.12 and the demo ran successfully.

fisakhan commented 3 years ago

@rakaar what version of the cuda and cudnn did you use for TensorFlow==1.12? Can we run it on CPU only without having need for cuda? I use TensorFlow==2.4 and CUDA==11 and ended with a similar problem https://github.com/microsoft/Deep3DFaceReconstruction/issues/139

fisakhan commented 3 years ago

Can someone provide pre-compiled binary file rasterize_triangles_kernel.so that can work with TensorFlow >= 2.0 ?

rakaar commented 3 years ago

@fisakhan It doesn't work with TensorFlow version 2.0, you need to degrade the tensorflow version to 1.12 (ref) And I think CUDA is necessary, I tried running without CUDA, it didn't work.

arixlin commented 3 years ago

tensorflow1.x

!/bin/bash

TF_INC=$(python3 -c "import tensorflow as tf; print(tf.sysconfig.get_include())") TF_LIB=$(python3 -c "import tensorflow as tf; print(tf.sysconfig.get_lib())")

echo "TF_INC: $TF_INC" >&2 echo "TF_LIB: $TF_LIB" >&2

if tensorflow2.x

(cd $TF_LIB && ln -sf libtensorflow_framework.so.2 libtensorflow_framework.so)

TF_MESH_RENDERER_PATH=$PWD/tf_mesh_renderer/mesh_renderer/kernels/

g++ -std=c++11 \ -shared \ $TF_MESH_RENDERER_PATH/rasterize_triangles_grad.cc \ $TF_MESH_RENDERER_PATH/rasterize_triangles_op.cc \ $TF_MESH_RENDERER_PATH/rasterize_triangles_impl.cc \ $TF_MESH_RENDERER_PATH/rasterize_triangles_impl.h \ -o $TF_MESH_RENDERER_PATH/rasterize_triangles_kernel.so \ -fPIC -D_GLIBCXX_USE_CXX11_ABI=0 \ -I$TF_INC -L$TF_LIB -ltensorflow_framework -O2

if [ "$?" -ne 0 ]; then echo "compile rasterizer failed"; exit 1; fi