apache / mxnet

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
https://mxnet.apache.org
Apache License 2.0
20.77k stars 6.79k forks source link

MXNet MinGW-w64 build error #9944

Open qingyuanxingsi opened 6 years ago

qingyuanxingsi commented 6 years ago

Description

Trying to build mxnet cpp package in Windows 7 using MinGW-w64, meeting following error.

Environment info (Required)

Windows 7

Build info (Required if built from source)

Compiler (gcc/clang/mingw/visual studio): mingw-w64

MXNet commit hash: 661bcef3204f18ff4cb1879f06b3767fe9d226b5

Build config:

CMakeLists.txt

CMAKE Info

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: D:/msys64/mingw64/bin/gcc.exe
-- Check for working C compiler: D:/msys64/mingw64/bin/gcc.exe -- 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: D:/msys64/mingw64/bin/g++.exe
-- Check for working CXX compiler: D:/msys64/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SUPPORT_CXX11
-- Performing Test SUPPORT_CXX11 - Success
-- Performing Test SUPPORT_CXX0X
-- Performing Test SUPPORT_CXX0X - Success
-- Performing Test SUPPORT_MSSE2
-- Performing Test SUPPORT_MSSE2 - Success
-- Found OpenBLAS libraries: F:/tools/mxnet/3rdparty/OpenBLAS/lib/openblas.lib
-- Found OpenBLAS include: F:/tools/mxnet/3rdparty/OpenBLAS/include
-- OpenCV Disabled
-- Found PythonInterp: D:/Anaconda3/python.exe (found version "3.6.1") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found GTest: gtest  
-- Configuring done
-- Generating done
-- Build files have been written to: F:/tools/mxnet/cmake-build-debug

Error Message:

[ 73%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/core/op.cc.obj
[ 73%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/core/pass.cc.obj
[ 74%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/core/symbolic.cc.obj
[ 74%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/gradient.cc.obj
[ 75%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/infer_shape_type.cc.obj
[ 75%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/order_mutation.cc.obj
[ 76%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/place_device.cc.obj
[ 76%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/plan_memory.cc.obj
[ 77%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/print_graph_ir.cc.obj
[ 77%] Building CXX object CMakeFiles/mxnet.dir/nnvm/src/pass/saveload_json.cc.obj
[ 77%] Linking CXX shared library libmxnet.dll
D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Error: export ordinal too large: 69148
CMakeFiles\mxnet.dir/objects.a(c_api_error.cc.obj): In function `MXGetLastError':
F:/tools/mxnet/src/c_api/c_api_error.cc:29: undefined reference to `__imp_NNGetLastError'
CMakeFiles\mxnet.dir/objects.a(c_api_error.cc.obj): In function `MXAPISetLastError(char const*)':
F:/tools/mxnet/src/c_api/c_api_error.cc:33: undefined reference to `__imp_NNAPISetLastError'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXListAllOpNames':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:78: undefined reference to `__imp_NNListAllOpNames'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolListAtomicSymbolCreators':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:85: undefined reference to `__imp_NNListUniqueOps'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolGetAtomicSymbolInfo':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:110: undefined reference to `__imp_NNGetOpInfo'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolCreateVariable':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:148: undefined reference to `__imp_NNSymbolCreateVariable'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolCreateGroup':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:154: undefined reference to `__imp_NNSymbolCreateGroup'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolGetOutput':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:160: undefined reference to `__imp_NNSymbolGetOutput'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolFree':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:182: undefined reference to `__imp_NNSymbolFree'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolCopy':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:186: undefined reference to `__imp_NNSymbolCopy'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolPrint':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:190: undefined reference to `__imp_NNSymbolPrint'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolGetName':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:196: undefined reference to `__imp_NNSymbolGetAttr'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolListOutputs':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:310: undefined reference to `__imp_NNSymbolListOutputNames'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolGetNumOutputs':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:315: undefined reference to `__imp_NNSymbolGetNumOutputs'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolCompose':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:323: undefined reference to `__imp_NNSymbolCompose'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolListArguments':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:330: undefined reference to `__imp_NNSymbolListInputNames'
CMakeFiles\mxnet.dir/objects.a(c_api_symbolic.cc.obj): In function `MXSymbolListAuxiliaryStates':
F:/tools/mxnet/src/c_api/c_api_symbolic.cc:336: undefined reference to `__imp_NNSymbolListInputNames'
CMakeFiles\mxnet.dir/objects.a(c_predict_api.cc.obj): In function `MXPredCreatePartialOut':
F:/tools/mxnet/src/c_api/c_predict_api.cc:111: undefined reference to `__imp_MXListAllOpNames'
CMakeFiles\mxnet.dir/objects.a(c_api_graph.cc.obj): In function `NNAPIHandleException(dmlc::Error const&)':
F:/tools/mxnet/nnvm/src/c_api/c_api_common.h:53: undefined reference to `__imp_NNAPISetLastError'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [CMakeFiles\mxnet.dir\build.make:4176: libmxnet.dll] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:963: CMakeFiles/mxnet.dir/all] Error 2
mingw32-make.exe: *** [Makefile:140: all] Error 2

Minimum reproducible example

(If you are using your own code, please provide a short script that reproduces the error. Otherwise, please provide link to the existing example.)

Steps to reproduce

(Paste the commands you ran that produced the error.)

1. 2.

What have you tried to solve it?

1.Remove MXNET_DLL in this line https://github.com/apache/incubator-mxnet/blob/master/src/c_api/c_api.cc#L387, which triggered a bug during compilation 2.

sxjscience commented 6 years ago

I think you can try to use Visual Studio instead. In fact, compiling by "Visual Studio" could be very simple after you get familiar with the tool. You can try to follow the Windows Installation Guide. It uses VS2015 + CMake.

qingyuanxingsi commented 6 years ago

@sxjscience

Actually I have tried build mxnet cpp package in various platforms, including linux, mac os and Windows, however it is really painful to build mxnet in Windows. Linux and mac works quite fine.

Building mxnet cpp package using VS 2017 got following error:

9>"Running: python OpWrapperGenerator.py F:/tools/mxnet/vs_build/Debug/libmxnet.dll"
10>------ 已启动生成: 项目: mlp, 配置: Debug x64 ------
11>------ 已启动生成: 项目: alexnet, 配置: Debug x64 ------
12>------ 已启动生成: 项目: charRNN, 配置: Debug x64 ------
13>------ 已启动生成: 项目: googlenet, 配置: Debug x64 ------
14>------ 已启动生成: 项目: inception_bn, 配置: Debug x64 ------
15>------ 已启动生成: 项目: lenet, 配置: Debug x64 ------
16>------ 已启动生成: 项目: lenet_with_mxdataiter, 配置: Debug x64 ------
17>------ 已启动生成: 项目: mlp_cpu, 配置: Debug x64 ------
10>mlp.cpp
12>charRNN.cpp
13>googlenet.cpp
17>mlp_cpu.cpp
14>inception_bn.cpp
11>alexnet.cpp
15>lenet.cpp
13>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
17>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
14>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
10>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
13>已完成生成项目“googlenet.vcxproj”的操作 - 失败。
17>已完成生成项目“mlp_cpu.vcxproj”的操作 - 失败。
10>已完成生成项目“mlp.vcxproj”的操作 - 失败。
14>已完成生成项目“inception_bn.vcxproj”的操作 - 失败。
18>------ 已启动生成: 项目: cpp_package_deploy_library, 配置: Debug x64 ------
19>------ 已启动生成: 项目: mlp_gpu, 配置: Debug x64 ------
20>------ 已启动生成: 项目: resnet, 配置: Debug x64 ------
12>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
15>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
19>mlp_gpu.cpp
12>已完成生成项目“charRNN.vcxproj”的操作 - 失败。
15>已完成生成项目“lenet.vcxproj”的操作 - 失败。
11>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
11>已完成生成项目“alexnet.vcxproj”的操作 - 失败。
19>LINK : fatal error LNK1104: 无法打开文件“mxnet_static.lib”
19>已完成生成项目“mlp_gpu.vcxproj”的操作 - 失败。
21>------ 已跳过生成: 项目: INSTALL, 配置: Debug x64 ------
21>没有为此解决方案配置选中要生成的项目 
========== 生成: 成功 2 个,失败 10 个,最新 7 个,跳过 9 个 ==========
  1. How to fix the windows build error??
  2. Can mxnet built using mingw??If so, would be tell me how to solve the mingw build problem???
  3. If possible, I strongly suggest you add a tutorial on how to solve common build problems on different platforms!

Much thanks!

sxjscience commented 6 years ago

I haven’t tried VS2017 and MinGW. I’ve only successfully compiled the package using VS2015. You can try the same software configurations as described in the doc.

qingyuanxingsi commented 6 years ago

@sxjscience

OK, I can download VS 2015 and give it a try! Can anyone in the team give some instructions on building mxnet using MinGW/MinGW-w64/cygwin??

lebeg commented 6 years ago

Hm, I'm not sure about the build messages you've posted, but I assume that cpp package build is broken on windows. Can you try building with -DUSE_CPP_PACKAGE=0 if you don't need it for now?

I will check the windows build.

qingyuanxingsi commented 6 years ago

@lebeg When can the windows build be fixed??Actually I do need the cpp package! Inform me if fixed, much thanks!

EternalSaga commented 6 years ago

I encountered the similar error when I was building the cpp package examples in VS2015

lebeg commented 6 years ago

Totally forgot about this issue, did this get resolved?

qingyuanxingsi commented 6 years ago

@lebeg I didn't give it a second try, if there is no modification to the build script, the issue remains.

eitan3 commented 6 years ago

@lebeg I'm having the same bug.. I'm trying to compile mxnet for Windows 10 from VS2015. without DUSE_CPP_PACKAGE mxnet compile perfectly, with cpp package it doesnt..

I think the problem here is something with the DLL. when I run the OpWrapperGenerator.py file it output an error "OSError: [WinError 126] The specified module could not be found" I checked if the first argument is the dll, and it exists in the right path..

lebeg commented 6 years ago

What if you try a suggestion from https://github.com/apache/incubator-mxnet/issues/10543 - make sure you have python and all needed modules installed and it's on the PATH and that you run 2 consecutive builds - 1 without cpp package and another with.