deephealthproject / workshops

DeepHealth project workshops / hackathons
1 stars 2 forks source link

Everything installs correctly, but import fails #3

Open Andrea-Oliveri opened 4 years ago

Andrea-Oliveri commented 4 years ago

Good Morning, I managed to install all libraries correctly following this. To compile everything, I always used gcc8 from the devtoolset-8. Unfortunately, when I try to run python padchest_train.py (and my eddl conda environment is activated) I get an error:

Traceback (most recent call last):
  File "padchest_train.py", line 4, in <module>
    from pyeddl import eddl
  File "/home/oliveri/shares/local/scrap/miniconda3/envs/eddl/lib/python3.8/site-packages/pyeddl-0.6.0-py3.8-linux-x86_64.egg/pyeddl/eddl.py", line 21, in <module>
    from . import _core
ImportError: /scrap/users/oliveri/hackatlon//installs/install_eddl/lib/libeddl.so: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv

Looking on the internet, and specifically here the issue seems to be related to different versions of gcc, or to a flag, which leads to names mismatches between the function entry points in libeddl.so and libprotobuf.so. As I said, I made sure to always use gcc8 for the whole process. I double-checked that libeddl.so was correctly linked to libprotobuf.so:

$ldd -r /scrap/users/oliveri/hackatlon//installs/install_eddl/lib/libeddl.so
        linux-vdso.so.1 =>  (0x00007ffcf9df9000)
        libcublas.so.10 => /lib64/libcublas.so.10 (0x00007fe71251b000)
        libcudart.so.10.1 => /usr/local/cuda-10.1/lib64/libcudart.so.10.1 (0x00007fe71229f000)
        libcurand.so.10 => /usr/local/cuda-10.1/lib64/libcurand.so.10 (0x00007fe70e23e000)
        libz.so.1 => /lib64/libz.so.1 (0x00007fe70e028000)
        libprotobuf.so.22 => /scrap/users/oliveri/hackatlon/installs/install_protobuf/lib/libprotobuf.so.22 (0x00007fe70db70000)
        libgomp.so.1 => /lib64/libgomp.so.1 (0x00007fe70d94a000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe70d72e000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fe70d526000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fe70d322000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fe70d01b000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fe70cd19000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fe70cb03000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fe70c735000)
        libcublasLt.so.10 => /lib64/libcublasLt.so.10 (0x00007fe70a8a2000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fe71721d000)

and then I checked that libprotobuf.so contained the undefined symbol: strings /scrap/users/oliveri/hackatlon//installs/install_protobuf/lib/libprotobuf.so | grep _ZNK6google8protobuf7Message11GetTypeNameEv had 3 matches. At this point, I really don't see where the issue could be... Thank you in advance for your help.

sanromra commented 4 years ago

Good morning, Andrea!

Seems that there is some problem with linking protobuf when compiling eddl. Let's try one thing. With the environment set up as you have (and all the environment variables properly set up) try to run again the eddl cmake command line, which according to the bitácora is: $cmake -D BUILD_SHARED_LIB=ON -D BUILD_PROTOBUF=ON -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=${HOME}/installs/install_eddl -D CMAKE_PREFIX_PATH=${HOME}/installs/install_protobuf ..

After that, copy and paste here cmake output so we can see if CMAKE is detecting protobuf in your machine.

Andrea-Oliveri commented 4 years ago
(eddl) $ cmake -D BUILD_SHARED_LIB=ON -D BUILD_PROTOBUF=ON -D BUILD_TESTS=OFF -D CMAKE_INSTALL_PREFIX=/scrap/users/oliveri/hackatlon/installs/install_eddl -D CMAKE_PREFIX_PATH=/scrap/users/oliveri/hackatlon/instal
ls/install_protobuf ..

running /scrap/users/oliveri/hackatlon/installs/install_protobuf/bin/protoc --cpp_out /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/src/serialization/onnx/ --proto_path /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/src/serialization/onnx/ onnx.proto  2>&1
-- Found OpenMP, version 4
Protobuf path: /scrap/users/oliveri/hackatlon/installs/install_protobuf/lib/libprotobuf.so;-pthread /scrap/users/oliveri/hackatlon/installs/install_protobuf/include
-- Install path: /scrap/users/oliveri/hackatlon/installs/install_eddl
-- ===========================================
-- ===========================================
-- Project name: eddl
-- Prefix path: /scrap/users/oliveri/hackatlon/installs/install_protobuf
-- Install prefix: /scrap/users/oliveri/hackatlon/installs/install_eddl
-- Archive output directory: /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/build/lib64
-- Library output directory: /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/build/lib64
-- Runtime output directory: /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/build/bin
-- -------------------------------------------
-- Build target: GPU
-- Build type: Release
-- Build tests: OFF
-- Build examples: ON
-- -------------------------------------------
-- Use OpenMP: ON
-- Use Protobuf: ON
-- Use HPC:
-- Use Intel-MKL:
-- -------------------------------------------
-- C++ compiler: GNU (/opt/rh/devtoolset-8/root/usr/bin/g++)
-- C++ flags:  -fprofile-arcs -ftest-coverage -DEIGEN_FAST_MATH -pipe
-- C++ flags (release): -O3 -mtune=native
-- C++ flags (debug): -g -Og
-- -------------------------------------------
-- CUDA Enabled: ON
-- CUDA compiler: /usr/local/cuda-10.1/bin/nvcc
-- CUDA flags:  --expt-relaxed-constexpr -D_MWAITXINTRIN_H_INCLUDED -D_FORCE_INLINES -D__STRICT_ANSI__
-- CUDA toolkit: /usr/local/cuda-10.1/targets/x86_64-linux/include
-- -------------------------------------------
-- OpenMP version: 4
-- OpenMP gomp library: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libgomp.so
-- OpenMP pthread library: /lib64/libpthread.so
-- -------------------------------------------
-- Protobuf: /scrap/users/oliveri/hackatlon/installs/install_protobuf/include
-- Protobuf compiler: /scrap/users/oliveri/hackatlon/installs/install_protobuf/bin/protoc
-- -------------------------------------------
-- Eigen3: /home/oliveri/shares/local/scrap/miniconda3/envs/eddl/include/eigen3
-- ZLIB: /usr/include
-- ===========================================
-- ===========================================
-- Configuring done
CMake Warning at CMakeLists.txt:235 (add_library):
  Cannot generate a safe linker search path for target eddl because files in
  some directories may conflict with libraries in implicit directories:

    link library [libgomp.so] in /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8 may be hidden by files in:
      /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7

  Some of these libraries may not be found correctly.

-- Generating done
-- Build files have been written to: /scrap/users/oliveri/hackatlon/temp/pyecvl/third_party/pyeddl/third_party/eddl/build
sanromra commented 4 years ago

Perfect, Andrea. Seems that cmake is detecting protobuf properly.

Can you execute $echo $LD_LIBRARY_PATH and send us the output?

Thanks.

Andrea-Oliveri commented 4 years ago
(eddl) $ echo $LD_LIBRARY_PATH
/usr/local/cuda-10.1/lib64/:/usr/local/cuda-10.1/libnsight/:/usr/local/cuda-10.1/libnvvp/:/scrap/users/oliveri/hackatlon/installs/install_opencv/lib:/scrap/users/oliveri/hackatlon/installs/install_protobuf/lib:/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib:/opt/rh/devtoolset-8/root/usr/lib64/dyninst:/opt/rh/devtoolset-8/root/usr/lib/dyninst:/opt/rh/devtoolset-8/root/usr/lib64:/opt/rh/devtoolset-8/root/usr/lib
sanromra commented 4 years ago

It also seems good.

Let's double check also the content of $EDDL_DIR, $ECVL_DIRand $CPATH

Andrea-Oliveri commented 4 years ago
(eddl) $ echo $EDDL_DIR
/scrap/users/oliveri/hackatlon//installs/install_eddl
(eddl) $ echo $ECVL_DIR
/scrap/users/oliveri/hackatlon//installs/install_ecvl
(eddl) $ echo $CPATH
/scrap/users/oliveri/hackatlon//installs/install_opencv/include/opencv4/:/scrap/users/oliveri/miniconda3/envs/eddl/include/eigen3:
Andrea-Oliveri commented 4 years ago

I installed the whole thing disabling protobuf (using -DBUILD_PROTOBUF=OFF in the eddl cmake and export EDDL_WITH_PROTOBUF=OFF before running python setup.py install inside pyeddl). Now the import of pyeddl works (of course I can't use the onnx functions), however the import of pyecvl fails:

(eddl) $ python pneumothorax_segmentation_training.py
Traceback (most recent call last):
  File "pneumothorax_segmentation_training.py", line 37, in <module>
    import pyecvl.ecvl as ecvl
  File "/home/oliveri/shares/local/scrap/miniconda3/envs/eddl/lib/python3.8/site-packages/pyecvl-0.3.0-py3.8-linux-x86_64.egg/pyecvl/ecvl.py", line 21, in <module>
    from . import _core
ImportError: libopencv_core.so.4.1: cannot open shared object file: No such file or directory