Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Failed to build mxnet from source #19664

Closed
shroudie opened this issue Dec 13, 2020 · 11 comments
Closed

Failed to build mxnet from source #19664

shroudie opened this issue Dec 13, 2020 · 11 comments

Comments

@shroudie
Copy link

Description

Hello all, I was trying to build mxnet from source (for tensorrt support), but errors occurred during build process.

Error Message

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_4bef8 && [1/2] Building C object CMakeFiles/cmTC_4bef8.dir/src.c.o
[2/2] Linking C executable cmTC_4bef8
FAILED: cmTC_4bef8
: && /usr/bin/cc -Wall -Wno-sign-compare -O3 -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_4bef8.dir/src.c.o -o cmTC_4bef8 && :
CMakeFiles/cmTC_4bef8.dir/src.c.o: In function main': src.c:(.text.startup+0x23): undefined reference to pthread_create'
src.c:(.text.startup+0x2c): undefined reference to pthread_detach' src.c:(.text.startup+0x35): undefined reference to pthread_cancel'
src.c:(.text.startup+0x40): undefined reference to pthread_join' src.c:(.text.startup+0x4b): undefined reference to pthread_atfork'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Source file was:
#include <pthread.h>

void* test_func(void* data)
{
return data;
}

int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_cancel(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);

return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_3f333 && [1/2] Building C object CMakeFiles/cmTC_3f333.dir/CheckFunctionExists.c.o
[2/2] Linking C executable cmTC_3f333
FAILED: cmTC_3f333
: && /usr/bin/cc -Wall -Wno-sign-compare -O3 -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_3f333.dir/CheckFunctionExists.c.o -o cmTC_3f333 -lpthreads && :
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Determining if the OPENBLAS_USE64BITINT exist failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_d0797 && [1/2] Building C object CMakeFiles/cmTC_d0797.dir/CheckSymbolExists.c.o
FAILED: CMakeFiles/cmTC_d0797.dir/CheckSymbolExists.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -fPIE -o CMakeFiles/cmTC_d0797.dir/CheckSymbolExists.c.o -c CheckSymbolExists.c
CheckSymbolExists.c: In function ‘main’:
CheckSymbolExists.c:8:19: error: ‘OPENBLAS_USE64BITINT’ undeclared (first use in this function); did you mean ‘OPENBLAS___64BIT__’?
return ((int*)(&OPENBLAS_USE64BITINT))[argc];
^~~~~~~~~~~~~~~~~~~~
OPENBLAS___64BIT__
CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
ninja: build stopped: subcommand failed.

File /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include </usr/include/x86_64-linux-gnu/openblas_config.h>

int main(int argc, char** argv)
{
(void)argv;
#ifndef OPENBLAS_USE64BITINT
return ((int*)(&OPENBLAS_USE64BITINT))[argc];
#else
(void)argc;
return 0;
#endif
}
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_UNUSED_LOCAL_TYPEDEF_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_df535 && [1/2] Building C object CMakeFiles/cmTC_df535.dir/src.c.o
FAILED: CMakeFiles/cmTC_df535.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_UNUSED_LOCAL_TYPEDEF_FLAG -fPIE -Wunused-local-typedef -o CMakeFiles/cmTC_df535.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wunused-local-typedef'; did you mean '-Wunused-local-typedefs'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_COVERED_SWITCH_DEFAULT_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_9e84d && [1/2] Building C object CMakeFiles/cmTC_9e84d.dir/src.c.o
FAILED: CMakeFiles/cmTC_9e84d.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_COVERED_SWITCH_DEFAULT_FLAG -fPIE -Wcovered-switch-default -o CMakeFiles/cmTC_9e84d.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wcovered-switch-default'; did you mean '-Wno-switch-default'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_DEPRECATED_REGISTER_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_507ea && [1/2] Building C object CMakeFiles/cmTC_507ea.dir/src.c.o
FAILED: CMakeFiles/cmTC_507ea.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_DEPRECATED_REGISTER_FLAG -fPIE -Wdeprecated-register -o CMakeFiles/cmTC_507ea.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wdeprecated-register'; did you mean '-frename-registers'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_GNU_ANONYMOUS_STRUCT_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_eadb2 && [1/2] Building C object CMakeFiles/cmTC_eadb2.dir/src.c.o
FAILED: CMakeFiles/cmTC_eadb2.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_GNU_ANONYMOUS_STRUCT_FLAG -fPIE -Wgnu-anonymous-struct -o CMakeFiles/cmTC_eadb2.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wgnu-anonymous-struct'
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_SELF_ASSIGN_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_9923d && [1/2] Building C object CMakeFiles/cmTC_9923d.dir/src.c.o
FAILED: CMakeFiles/cmTC_9923d.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_SELF_ASSIGN_FLAG -fPIE -Wself-assign -o CMakeFiles/cmTC_9923d.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wself-assign'; did you mean '-Wcast-align'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_VLA_EXTENSION_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_43847 && [1/2] Building C object CMakeFiles/cmTC_43847.dir/src.c.o
FAILED: CMakeFiles/cmTC_43847.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_VLA_EXTENSION_FLAG -fPIE -Wvla-extension -o CMakeFiles/cmTC_43847.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wvla-extension'; did you mean '-fms-extensions'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_WNO_FORMAT_PEDANTIC_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_b1681 && [1/2] Building C object CMakeFiles/cmTC_b1681.dir/src.c.o
FAILED: CMakeFiles/cmTC_b1681.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_WNO_FORMAT_PEDANTIC_FLAG -fPIE -Wformat-pedantic -o CMakeFiles/cmTC_b1681.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-Wformat-pedantic'; did you mean '-Wno-pedantic'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_MMIC_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_0792e && [1/2] Building C object CMakeFiles/cmTC_0792e.dir/src.c.o
FAILED: CMakeFiles/cmTC_0792e.dir/src.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_MMIC_FLAG -mmic -fPIE -mmic -o CMakeFiles/cmTC_0792e.dir/src.c.o -c src.c
cc: error: unrecognized command line option '-mmic'; did you mean '-fpic'?
cc: error: unrecognized command line option '-mmic'; did you mean '-fpic'?
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Performing C SOURCE FILE Test LIBOMP_HAVE_M32_FLAG failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_8e862 && [1/2] Building C object CMakeFiles/cmTC_8e862.dir/src.c.o
[2/2] Linking C executable cmTC_8e862
FAILED: cmTC_8e862
: && /usr/bin/cc -Wall -Wno-sign-compare -O3 -DLIBOMP_HAVE_M32_FLAG -m32 CMakeFiles/cmTC_8e862.dir/src.c.o -o cmTC_8e862 && :
/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Source file was:
int main(void) { return 0; }
Determining if files windows.h;psapi.h exist failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_056e1 && [1/2] Building C object CMakeFiles/cmTC_056e1.dir/LIBOMP_HAVE_PSAPI_H.c.o
FAILED: CMakeFiles/cmTC_056e1.dir/LIBOMP_HAVE_PSAPI_H.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -fPIE -o CMakeFiles/cmTC_056e1.dir/LIBOMP_HAVE_PSAPI_H.c.o -c /home/shunfan/Documents/mxnet/build/CMakeFiles/CheckIncludeFiles/LIBOMP_HAVE_PSAPI_H.c
/home/shunfan/Documents/mxnet/build/CMakeFiles/CheckIncludeFiles/LIBOMP_HAVE_PSAPI_H.c:2:10: fatal error: windows.h: No such file or directory
#include <windows.h>
^~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

Source:
/* */
#include <windows.h>
#include <psapi.h>

int main(void){return 0;}

Determining if the function EnumProcessModules exists in the psapi failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_1b5a9 && [1/2] Building C object CMakeFiles/cmTC_1b5a9.dir/CheckFunctionExists.c.o
[2/2] Linking C executable cmTC_1b5a9
FAILED: cmTC_1b5a9
: && /usr/bin/cc -Wall -Wno-sign-compare -O3 -DCHECK_FUNCTION_EXISTS=EnumProcessModules CMakeFiles/cmTC_1b5a9.dir/CheckFunctionExists.c.o -o cmTC_1b5a9 -lpsapi && :
/usr/bin/ld: cannot find -lpsapi
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Determining if the function __atomic_load_1 exists failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_79cae && [1/2] Building C object CMakeFiles/cmTC_79cae.dir/CheckFunctionExists.c.o
:0:23: warning: conflicting types for built-in function ‘__atomic_load_1’ [-Wbuiltin-declaration-mismatch]
/usr/local/share/cmake-3.18/Modules/CheckFunctionExists.c:7:3: note: in expansion of macro ‘CHECK_FUNCTION_EXISTS’
CHECK_FUNCTION_EXISTS(void);
^~~~~~~~~~~~~~~~~~~~~
[2/2] Linking C executable cmTC_79cae
FAILED: cmTC_79cae
: && /usr/bin/cc -Wall -Wno-sign-compare -O3 -DCHECK_FUNCTION_EXISTS=__atomic_load_1 -rdynamic CMakeFiles/cmTC_79cae.dir/CheckFunctionExists.c.o -o cmTC_79cae && :
CMakeFiles/cmTC_79cae.dir/CheckFunctionExists.c.o: In function main': CheckFunctionExists.c:(.text.startup+0xc): undefined reference to __atomic_load_1'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Determining if the fopen64 exist failed with the following output:
Change Dir: /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_33bc3 && [1/2] Building C object CMakeFiles/cmTC_33bc3.dir/CheckSymbolExists.c.o
FAILED: CMakeFiles/cmTC_33bc3.dir/CheckSymbolExists.c.o
/usr/bin/cc -Wall -Wno-sign-compare -O3 -fopenmp -fPIE -o CMakeFiles/cmTC_33bc3.dir/CheckSymbolExists.c.o -c CheckSymbolExists.c
CheckSymbolExists.c: In function ‘main’:
CheckSymbolExists.c:8:19: error: ‘fopen64’ undeclared (first use in this function); did you mean ‘fopen’?
return ((int*)(&fopen64))[argc];
^~~~~~~
fopen
CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
ninja: build stopped: subcommand failed.

File /home/shunfan/Documents/mxnet/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <stdio.h>

int main(int argc, char** argv)
{
(void)argv;
#ifndef fopen64
return ((int*)(&fopen64))[argc];
#else
(void)argc;
return 0;
#endif
}

To Reproduce

cmake -DUSE_CUDA=1 -DUSE_TENSORRT=1 -G Ninja ..

Environment

----------Python Info----------
Version : 3.6.9
Compiler : GCC 8.4.0
Build : ('default', 'Oct 8 2020 12:12:24')
Arch : ('64bit', 'ELF')
------------Pip Info-----------
Version : 20.2.4
Directory : /.local/lib/python3.6/site-packages/pip
----------MXNet Info-----------
No MXNet installed.
----------System Info----------
Platform : Linux-5.4.0-56-generic-x86_64-with-Ubuntu-18.04-bionic
system : Linux
node : shunfan-pc
release : 5.4.0-56-generic
version : #62
18.04.1-Ubuntu SMP Tue Nov 24 10:07:50 UTC 2020
----------Hardware Info----------
machine : x86_64
processor : x86_64
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 6
On-line CPU(s) list: 0-5
Thread(s) per core: 1
Core(s) per socket: 6
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 158
Model name: Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz
Stepping: 10
CPU MHz: 3999.147
CPU max MHz: 4100.0000
CPU min MHz: 800.0000
BogoMIPS: 5799.77
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 9216K
NUMA node0 CPU(s): 0-5

@leezu
Copy link
Contributor

leezu commented Dec 14, 2020

Please provide the build configuration log.

cc @Zha0q1 due to the CheckSymbolExists.c:8:19: error: ‘OPENBLAS_USE64BITINT’ undeclared (first use in this function); did you mean ‘OPENBLAS___64BIT__’? above

@shroudie
Copy link
Author

Please provide the build configuration log.

cc @Zha0q1 due to the CheckSymbolExists.c:8:19: error: ‘OPENBLAS_USE64BITINT’ undeclared (first use in this function); did you mean ‘OPENBLAS___64BIT__’? above

Were you talking about CMakeOutput.log? It is quite long, I've uploaded to Drive and shared with this link. Thanks,

@leezu
Copy link
Contributor

leezu commented Dec 15, 2020

I mean the output of the cmake command prior to running make or ninja. Sorry for the confusion

@shroudie
Copy link
Author

I mean the output of the cmake command prior to running make or ninja. Sorry for the confusion

Thanks for the help. All I did was:

cp config/linux_gpu.cmake config.cmake

mkdir build && cd build

cmake -DUSE_CUDA=1 -DUSE_TENSORRT=1 ..

@leezu
Copy link
Contributor

leezu commented Dec 15, 2020

Yes, please provide the output of cmake -DUSE_CUDA=1 -DUSE_TENSORRT=1 .. with an empty build directory

@shroudie
Copy link
Author

cmake -DUSE_CUDA=1 -DUSE_TENSORRT=1 ..

Hi, I shared a file of full output in here, thanks!

@leezu
Copy link
Contributor

leezu commented Dec 15, 2020

You can see that -- Configuring incomplete, errors occurred!.

Please install gfortran, for example via sudo apt install gfortran as the /usr/lib/x86_64-linux-gnu/libopenblas.a uses the libgfortran.

cc @mseth10 do you think we should detect libgfortran even if gfortran compiler is not present?

@mseth10
Copy link
Contributor

mseth10 commented Dec 16, 2020

We didn't have to install gfortran separately before. But now with @Zha0q1 's recent commit on statically linking openblas, we have to install it separately. @Zha0q1 can you update the build instructions with this update?

@shroudie
Copy link
Author

It is all working fine now, thanks a lot!

@Zha0q1
Copy link
Contributor

Zha0q1 commented Dec 16, 2020

Please provide the build configuration log.

cc @Zha0q1 due to the CheckSymbolExists.c:8:19: error: ‘OPENBLAS_USE64BITINT’ undeclared (first use in this function); did you mean ‘OPENBLAS___64BIT__’? above

I think this is how cmake checks if a symbol exists. It tries to compile some dummy project and see it it succeeds

@Zha0q1
Copy link
Contributor

Zha0q1 commented Dec 16, 2020

I will update the build from source doc in instruct the user to install gfortran then

@leezu leezu closed this as completed Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants