Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference #1120

Closed
xuziye0327 opened this issue Jan 11, 2017 · 12 comments
Closed

undefined reference #1120

xuziye0327 opened this issue Jan 11, 2017 · 12 comments
Assignees

Comments

@xuziye0327
Copy link

/usr/local/cmake/bin/cmake .. -DWITH_GPU=ON -DCMAKE_INSTALL_PREFIX=/usr/local/paddle -DOPENBLAS_ROOT=/opt/OpenBLAS/ -DCUDNN_ROOT=/usr/local/cuda-8.0/
make -j && make install
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getrf<float>(CBLAS_ORDER, int, int, float*, int, int*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:91: undefined reference to `LAPACKE_sgetrf'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getrf<double>(CBLAS_ORDER, int, int, double*, int, int*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:105: undefined reference to `LAPACKE_dgetrf'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getri<float>(CBLAS_ORDER, int, float*, int, int const*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:118: undefined reference to `LAPACKE_sgetri'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getri<double>(CBLAS_ORDER, int, double*, int, int const*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:131: undefined reference to `LAPACKE_dgetri'
collect2: error: ld returned 1 exit status
make[2]: *** [paddle/math/tests/test_lazyAssign] Error 1
make[1]: *** [paddle/math/tests/CMakeFiles/test_lazyAssign.dir/all] Error 2
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getrf<float>(CBLAS_ORDER, int, int, float*, int, int*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:91: undefined reference to `LAPACKE_sgetrf'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getrf<double>(CBLAS_ORDER, int, int, double*, int, int*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:105: undefined reference to `LAPACKE_dgetrf'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getri<float>(CBLAS_ORDER, int, float*, int, int const*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:118: undefined reference to `LAPACKE_sgetri'
../libpaddle_math.a(MathFunctions.cpp.o): In function `int paddle::getri<double>(CBLAS_ORDER, int, double*, int, int const*)':
/root/tmp/paddle/paddle/math/MathFunctions.cpp:131: undefined reference to `LAPACKE_dgetri'
collect2: error: ld returned 1 exit status
make[2]: *** [paddle/math/tests/test_Tensor] Error 1
make[1]: *** [paddle/math/tests/CMakeFiles/test_Tensor.dir/all] Error 2
make: *** [all] Error 2

@gangliao
Copy link
Contributor

Can you show me your openblas lib dir?

ll /opt/OpenBLAS/lib 

@xuziye0327

@gangliao gangliao self-assigned this Jan 11, 2017
@gangliao
Copy link
Contributor

gangliao commented Jan 11, 2017

The problem in your case is caused by gfortran.so, which we did not link to Paddle.
You may need to export LD_LIBRARY_PATH=<gfortran_path>/lib:${LD_LIBRARY_PATH}.

@gangliao
Copy link
Contributor

gangliao commented Jan 11, 2017

@xuziye0327 Did you build openblas from source by yourself?

@gangliao
Copy link
Contributor

@xuziye0327
Can you also post git log info at here? Thanks a lot.

@xuziye0327
Copy link
Author

ll /opt/OpenBLAS/lib/
total 11796
drwxr-xr-x 3 root root    4096 Jan 10 22:29 cmake
lrwxrwxrwx 1 root root      30 Jan 10 22:29 libopenblas.a -> libopenblas_haswellp-r0.2.19.a
-rw-r--r-- 1 root root 7837314 Jan 10 22:29 libopenblas_haswellp-r0.2.19.a
-rwxr-xr-x 1 root root 4232264 Jan 10 22:29 libopenblas_haswellp-r0.2.19.so
lrwxrwxrwx 1 root root      31 Jan 10 22:29 libopenblas.so -> libopenblas_haswellp-r0.2.19.so
lrwxrwxrwx 1 root root      31 Jan 10 22:29 libopenblas.so.0 -> libopenblas_haswellp-r0.2.19.so

@xuziye0327
Copy link
Author

xuziye0327 commented Jan 11, 2017

git log
commit 30931f547749b6c85772927c66640fa6386c09db
Merge: 727edb8 bce067b
Author: gangliao <[email protected]>
Date:   Tue Jan 10 16:28:06 2017 +0800

    Merge pull request #1110 from reyoung/feature/add_third_party_for_gflags

    Make gflags third_party path configurable

commit 727edb873328f8163b40ef0f2339c60a79eb162e
Merge: 709c839 1e6c917
Author: hedaoyuan <[email protected]>
Date:   Tue Jan 10 16:06:51 2017 +0800

    Merge pull request #1109 from hedaoyuan/fix_issue_676

    fix unit test of paramRelu

commit bce067b002eb1660ea25d60bb1251376b3f157f6
Author: Yu Yang <[email protected]>
Date:   Tue Jan 10 15:41:22 2017 +0800

    Make gflags third_party path configurable

commit 1e6c917ecc76905fa0f33090d757f2b6376e437f
Author: hedaoyuan <[email protected]>
Date:   Tue Jan 10 15:30:24 2017 +0800

    fix unit test of paramRelu

commit 709c839af9584571d7bafe9490390deaca569fdf
Merge: 7df67ba af02d7c
Author: gangliao <[email protected]>
Date:   Tue Jan 10 14:25:58 2017 +0800

    Merge pull request #1103 from reyoung/feature/TravisCICacheThirdParty

    Feature/travis ci cache third party

@xuziye0327
Copy link
Author

yes i build openblas by myself

@xuziye0327
Copy link
Author

I can not find gfortran.so in my system.

@gangliao
Copy link
Contributor

gangliao commented Jan 11, 2017

@xuziye0327

You have two methods to fix the problem:

Method 1: You can directly download the release libraries of OpenBLAS or MKL. DO NOT BUILD IT BY YOURSELF.

Method 2: If you still want to build it from source, please make sure you have gfortran compiler in your system, which is located in gcc48/bin/gfortran. If you have it, then

cd openblas_dir
make CC=gcc48/bin/gcc FC=gcc48/bin/gfortran

@xuziye0327
Copy link
Author

Thanks!
But i get this error now.

[root@hpc1 build]# make -j `nproc` && make install
...
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(getcopyright.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(getplatform.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(getversion.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(structmember.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(parser.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(bytes_methods.o): relocation R_X86_64_32S against symbol `_Py_ctype_table' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: /usr/local/python2.7.13/lib/libpython2.7.a(getcompiler.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
make[2]: *** [../paddle/dist/.timestamp] Error 1
make[1]: *** [paddle/api/CMakeFiles/python_api_wheel.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Scanning dependencies of target test_Tensor
[ 99%] Linking CXX executable test_Tensor
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
[ 99%] Built target test_Tensor
make: *** [all] Error 2

When i used sudo, i got this.

[root@hpc1 build]# sudo make -j `nproc` && make install
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: BFD version 2.20.51.0.2-5.44.el6 20100205 internal error, aborting at reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make[2]: *** [paddle/gserver/tests/test_ConvUnify] Error 1
make[2]: *** Deleting file `paddle/gserver/tests/test_ConvUnify'
make[1]: *** [paddle/gserver/tests/CMakeFiles/test_ConvUnify.dir/all] Error 2
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: BFD version 2.20.51.0.2-5.44.el6 20100205 internal error, aborting at reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make[2]: *** [paddle/gserver/tests/test_PriorBox] Error 1
make[2]: *** Deleting file `paddle/gserver/tests/test_PriorBox'
make[1]: *** [paddle/gserver/tests/CMakeFiles/test_PriorBox.dir/all] Error 2
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: BFD version 2.20.51.0.2-5.44.el6 20100205 internal error, aborting at reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make[2]: *** [paddle/gserver/tests/test_LayerGrad] Error 1
make[2]: *** Deleting file `paddle/gserver/tests/test_LayerGrad'
make[1]: *** [paddle/gserver/tests/CMakeFiles/test_LayerGrad.dir/all] Error 2
...
...
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: BFD version 2.20.51.0.2-5.44.el6 20100205 internal error, aborting at reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make[2]: *** [paddle/math/tests/test_lazyAssign] Error 1
make[2]: *** Deleting file `paddle/math/tests/test_lazyAssign'
make[1]: *** [paddle/math/tests/CMakeFiles/test_lazyAssign.dir/all] Error 2
Scanning dependencies of target test_Tensor
[ 99%] Linking CXX executable test_Tensor
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7614: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
/usr/local/python2.7.13/lib/libpython2.7.a(posixmodule.o): In function `posix_tempnam':
/root/tmp/Python-2.7.13/./Modules/posixmodule.c:7561: warning: the use of `tempnam' is dangerous, better use `mkstemp'
/usr/bin/ld: BFD version 2.20.51.0.2-5.44.el6 20100205 internal error, aborting at reloc.c line 443 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

collect2: error: ld returned 1 exit status
make[2]: *** [paddle/math/tests/test_Tensor] Error 1
make[2]: *** Deleting file `paddle/math/tests/test_Tensor'
make[1]: *** [paddle/math/tests/CMakeFiles/test_Tensor.dir/all] Error 2
make: *** [all] Error 2

This is my g++ version:

[root@hpc1 build]# g++ --version
g++ (GCC) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@gangliao
Copy link
Contributor

Are you also build python from source ???

@gangliao
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants