mxnet build with intel mkl always throw error "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll." - c++

os : windows 10 64bits
compiler : vc2015 64bits update 3
mxnet : 1.3.1
Building mxnet 1.3.1(mxnet1.4.0 has bugs, can't build it under windows,please check14203 for more details).
I can build the mxnet with cpp-package, but when I call the forward function o the Executor, it keep throwing
Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.
Following are my steps to build the mxnet
git clone --recursive https://github.com/apache/incubator-mxnet mxnet
cd mxnet
Download intel mkl(w_mkl_2019.2.190.exe)
install it
open cmake3.11.0
I disable cpp_package,opencv,cuda,USE_MKLML_MKL(else mshadow will use openBLAS).
I disable USE_TENSORRT and USE_VTUNE too
press configure,disable BUILD_TESTING
press configure again, all green
press generate,all green
open ALL_BUILD.vcxproj
Select Release build
All build
All green, except install project fail
>file cannot create directory: C:/Program Files/mxnet/lib. Maybe need
1> administrative privileges.
Already open vc as admin, still the same error
Add Anaconda3 into PATH
Add libmxnet.dll and C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\redist\intel64_win\mkl\mkl_rt.dll into a folder which could be found by the os
select build with cpp_package from cmake gui
configure->generate
reopen ALL_BUILD.vcxproj
Select ALL_BUILD->build
Because install do not work,I copy the files lib to build_cpu/install
Because lrs and wds of op.h do not declare type,I need to add mx_float for them
write a simple program, can compile
When I call forward of the Executor,the program throw Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.
Add C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\redist\intel64_win\mkl的mkl_intel_thread.dll into the folder could be found by the os
26.Run again,still the same error Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll.
My Anaconda3 install mxnet,it got mkl_intel_thread.dll and mkl_rt.dll too,I wonder there are confliction,problem is I did not add the bin path of Anaconda3 into the PATH.
I tried to copy different mkl_intel_thread.dll and mkl_rt.dll into the folder where the exe at, but every combination of them give me same error.
Those dll come from following path
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.2.190\windows\redist\intel64_win\mkl
C:\Users\yyyy\Anaconda3\envs\gluon\Library\bin
C:\Users\yyyy\Anaconda3\Library\bin
C:\Users\yyyy\Anaconda3\pkgs\mkl-2019.1-144\Library\bin
Do anyone know how to solve this issue?Thanks

This problem should be caused by static MKL linkage, here's some advice may helpful to you.
Have you ever tried to set environmental variable for pre-load libs,
Here is Linux
export LD_PRELOAD=/opt/intel/mkl/lib/intel64/libmkl_def.so:/opt/intel/mkl/lib/intel64/libmkl_avx2.so:/opt/intel/mkl/lib/intel64/libmkl_core.so:/opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so:/opt/intel/mkl/lib/intel64/libmkl_intel_thread.so:/opt/intel/lib/intel64_lin/libiomp5.so
In windows, setting env by mkl/bin/mklvars.bat intel64, then run your python in same environment
or in python to add the library manually sys.path.append(" your path to the library") or Pyinstaller numpy "Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll"...
If above suggestions did not help, please try to modify the 'CMakeList.txt' file, change line 44 ~ 47 to single-dynamic linkage and re-cmake to install:
if(MSVC)
set(LIBS ${LIBS} mkl_rt ${MKL_COMPILER_LIB_FILE} PARENT_SCOPE)
else()
set(LIBS ${LIBS} mkl_rt ${MKL_COMPILER_LIB_FILE} PARENT_SCOPE)

Related

Build and run a Qt application on macOS via Bazel

I tried to build and run a Qt5 (5.15.2) application on macOS (10.15.7) using Bazel 5.0.0.
Unfortunately, I run into some problems.
The building part seems to work, but not the run part.
I installed Qt5 on my machine using Homebrew:
brew install qt#5
brew link qt#5
I adapted https://github.com/justbuchanan/bazel_rules_qt/ to my needs. See this PR. When I try to run:
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
I receive the runtime error:
dyld: Symbol not found: __ZN10QByteArray6_emptyE
Steps to reproduce the issue:
# brew install bazel # Install Bazel
# brew install qt#5 # Install Qt5
git clone https://github.com/Vertexwahn/bazel_rules_qt.git
cd bazel_rules_qt
git checkout add-macos-support
bazel build --cxxopt=-std=c++17 //... # should work
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main # should give you the error message
Nevertheless, building everything using bazel build --cxxopt=-std=c++17 //... seems to work.
I am not 100% sure if the link options -F/usr/local/opt/qt5/Frameworks and -framework QtCore, etc. are correct.
Maybe someone can confirm this.
Did I use the correct link options?
For me, it is a bit unclear what dependencies the main binary expects. I tried to copy QtCore.framework to the location of the main binary manually but this does not change the error message.
What files does the main binary expect?
If I try to run macdeployqt on my main binary I get also some errors. I do within my workspace root dir a cd bazel-bin/tests/qt_resource and run then /usr/local/opt/qt5/bin/macdeployqt main:
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "main"
WARNING: Perhaps macdeployqt was already used on "main" ?
WARNING: If so, you will need to rebuild "main" before trying again.
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/strip: can't open file: (No such file or directory)\n"
ERROR: ""
My hope was that macdeployqt would collect all needed resources for me. Any idea why this is not working?
How can macdeployqt be used to collect all needed dependencies for the main binary?
If I convert my main to an app via lipo -create -output universall_app main and do then a /usr/local/opt/qt5/bin/macdeployqt universall_app I get the same error message.
The CMake approach
To make sure that there is no general problem with my system setup I tried to use CMake to build a Qt5 application:
git clone https://github.com/euler0/mini-cmake-qt.git
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 .
make -j
This produces an example.app.
With a double click on this application bundle,
the application can be started.
This worked on my system.
Future directions
It seems that rules_apple can be used to create an application bundle.
I am not sure if I need to transform my Qt application binary to an app bundle to be able to execute it.
One could use --sandbox_debugto identify what Bazel is doing and dtruss for the CMake version to compare the differences.
I am currently not sure what trying to do next and hope for an easy solution. I am also fine with a Qt6 solution.
Update: Alternative Answer
It would also be helpful if someone can point out how to build a minimal Qt application using make only on macOS and a brew installed Qt5 or tell me what the linker and compiler options must look like.
I followed your steps with Mac OSX 10.15.7, Qt (installed by homebrew) 5.15.1 and both bazel 4.2.2-homebrew and 5.0.0-homebrew and initially I could not build the project from git:
* 3fe5f6c - (4 weeks ago) Add macOS support — Vertexwahn (HEAD -> add-macos-support, origin/add-macos-support)
This is the result that I get when building:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
INFO: Found 14 targets...
ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
#include <QtQml/QQmlApplicationEngine>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
INFO: Elapsed time: 0,594s, Critical Path: 0,32s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully
After playing around with headers and include paths in qt.BUILD:
diff --git a/qt.BUILD b/qt.BUILD
index 517c8db..8f110b5 100644
--- a/qt.BUILD
+++ b/qt.BUILD
## -28,11 +28,12 ## QT_LIBRARIES = [
cc_library(
name = "qt_%s_osx" % name,
# When being on Windows this glob will be empty
- hdrs = glob(["%s/**" % include_folder], allow_empty = True),
+ hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
includes = ["."],
linkopts = ["-F/usr/local/opt/qt5/lib"] + [
"-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
],
+ strip_include_prefix= "include"
# Available from Bazel 4.0.0
# target_compatible_with = ["#platforms//os:osx"],
)
I could build and run the project:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
INFO: Found 14 targets...
INFO: Elapsed time: 11,761s, Critical Path: 7,23s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
% bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tests/qt_resource:main up-to-date:
bazel-bin/tests/qt_resource/main
INFO: Elapsed time: 3,657s, Critical Path: 0,00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
opened resource file
file1
Related to your question whether the linker options are correct
-F/usr/local/opt/qt5/Frameworks -framework QtCore
Yes they are correct, you could alternatively use -F/usr/local/opt/qt5/lib (as you are already using in qt.BUILD) as all the files under the Frameworks folder are links to the lib folder.
With macdeployqt and lipo I get the same results as in the OP even after the test is running successfully.

linking of C++ and Python with BOOST; error = rule "Copyright" unknown in module "xml"

I am trying to execute linking of C++ and Python with BOOST.
Using the example from https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/hello.html#tutorial.hello.let_s_jam, and issuing bjam at ~/libs/python/example/tutorial/ which contains these files:
hello.cpp hello.py Jamfile
The read-out from the console error is:
/home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam:12:
in load ERROR: rule "Copyright" unknown in module "xml".
Here is what I undertook to solve this problem:
I built boost from boost_1_71_0.tar.bz2 using the ./b2 file in the directory /boost/boost_1_71_0/ which is dated November 14, 2019.
My Ubuntu 18.04 system has a b2 link at /usr/bin/b2 -> bjam, which is older (March 6, 2018) and the bjam file (March 6, 2018).
No other bjam files exist on the system.
From bjam for boost 1.54, I tried:
sudo-apt install bjam
error: E: Package 'bjam' has no installation candidate.
All the programs in the user-config.jam file (e.g., c++, msvc/code, python3) are correct, which is located in my /home/benjamin/boost/boost_1_71_0/tools/build/example/.
For pity's sake and to help me (newbie), please advise.
Looking at error message it seems that error is with file /home/benjamin/boost/boost_1_71_0/tools/build/src/tools/types/xml.jam
I checked with my local installation (which is boost 1.65.1), but I am not able to locate any file with name xml.jam. But I have few other .jam file at location /usr/share/boost-build/src/tools/types/. As example
asm.jam
# Copyright Craig Rodrigues 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
type ASM : s S asm ;
So it seems that your xml.jam either invalid OR few lines should be commented (as in above file).
Try below options.
Check your xml.jam, if there are any content which are not related jam then you should comment out information.
Rename your xml.jam to xml.jam.bkp. This file may not be needed.(Not needed in my case with boost 1.65.1)
Try to install everything from Ubuntu package manager and use that. You can install all boost module by sudo apt install libboost-all-dev. I tried https://github.com/boostorg/python/tree/develop/example code with my local installed boost (1.65.1) from package manager and it work fine.

Missing Jam file in fresh download of boost

I religiously follow http://www.boost.org/doc/libs/1_61_0/more/getting_started/windows.html.
After downloading and unpacking the 1.61 version of boost, I tried to build it from source with the instruction from section 5.1 in this guide.
So
bootstrap
.\b2
But then I get the error:
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory 'libs/config/checks/architecture'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile. [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
Exactly the same as Trac issue #12173 of boost.
What is going wrong? How can I make bjam find the jam files?
Bit out of date, but I was able to get this working by getting the config submodule:
git submodule update --init libs/config
It seems like the config module is an unlisted prerequisite for some of the other modules.
This error might happen when "bootstrap.jam" is trying to load the modules of the build system from a wrong path.
Make sure that BOOST_BUILD_PATH is set to "boost*/tools/build" and that BOOST_ROOT is unset.
Example of a WRONG config:
libtorrent-rasterbar-1.2.0>set BOOST_BUILD_PATH=..\boost_1_68_0
libtorrent-rasterbar-1.2.0>set BOOST_ROOT=..\boost_1_68_0
libtorrent-rasterbar-1.2.0>b2
Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = NT
building boost from source directory: ..\boost_1_68_0
boost_1_68_0/tools/build/src/build\project.jam:262: in find-jamfile from module project
error: Unable to load Jamfile.
error: Could not find a Jamfile in directory '../boost_1_68_0/libs/config/checks/architecture'.
error: Attempted to find it with pattern '[Bb]uild.jam [Jj]amfile.v2 [Jj]amfile [Jj]amfile. [Jj]amfile.jam'.
error: Please consult the documentation at 'http://www.boost.org'.
boost_1_68_0/tools/build/src/build\project.jam:325: in load-jamfile from module project
boost_1_68_0/tools/build/src/build\project.jam:64: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:89: in load-used-projects from module project
boost_1_68_0/tools/build/src/build\project.jam:75: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:89: in load-used-projects from module project
boost_1_68_0/tools/build/src/build\project.jam:75: in load from module project
boost_1_68_0/tools/build/src/build\project.jam:145: in project.find from module project
boost_1_68_0/tools/build/src\build-system.jam:618: in load from module build-system
..\boost_1_68_0\tools\build\src/kernel\modules.jam:295: in import from module modules
..\boost_1_68_0\tools\build\src/kernel/bootstrap.jam:139: in boost-build from module
..\boost_1_68_0\boost-build.jam:17: in module scope from module
Example of a FIXED config:
libtorrent-rasterbar-1.2.0>set BOOST_BUILD_PATH=..\boost_1_68_0\tools\build
libtorrent-rasterbar-1.2.0>set BOOST_ROOT=
libtorrent-rasterbar-1.2.0>b2
Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = NT
warning: No toolsets are configured.
warning: Configuring default toolset "msvc".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html
...patience...
...found 1058 targets...
...updating 163 targets...
msvc.write-setup-script bin\standalone\msvc\msvc-14.1\msvc-setup.bat
compile-c-c++ bin\msvc-14.1\debug\threading-multi\src\alert.obj
alert.cpp
...

dyn.load error linking a package with Rcpp

I've made an R package with Rcpp, to use the methods of a library I programmed in c++.
I've R running on the last version:
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04 LTS
I'm executing the following instruction to install my package:
> install.packages("mypackage", repos = NULL)
The package compiles well, I have the .o files of my source code, but in the linking phase I got the error:
* installing *source* package ‘rbdd’ ...
** libs
make: No se hace nada para 'all'.
installing to /home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs
** R
** preparing package for lazy loading
** help
Warning: /home/sergio/R/mypackage/man/mypackage-package.Rd:27: All text must be in a section
Warning: /home/sergio/R/mypackage/man/mypackage-package.Rd:28: All text must be in a section
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs/mypackage.so':
/home/sergio/R/x86_64-pc-linux-gnu-library/3.2/mypackage/libs/mypackage.so: undefined symbol: _ZN4cudd12defaultErrorENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE
Error: loading failed
Ejecución interrumpida
ERROR: loading failed
mypackge.so is created in the src folder of my package.
I've got a Makevars file (in src, too) with the following content:
PKG_CPPFLAGS=-I./buddy-2.5/src -I./cudd-3.0.0/cudd -I./cudd-3.0.0/mtr -I./cudd-3.0.0/cplusplus -I./cudd-3.0.0/dddmp -I./cudd-3.0.0/util -I./cudd-3.0.0 -isystem /usr/include/c++/v1 -std=c++11
PKG_LIBS=-lc++ -L/lib
and my NAMESPACE file has the lines:
useDynLib(mypackage)
exportPattern("^[[:alpha:]]+")
importFrom(Rcpp, evalCpp)
Someone knows how to solve this problem?
I am a little concerned about
PKG_LIBS=-lc++ -L/lib
Did you really mean /lib? If it is your library, a more common place would be /usr/local/lib which is also search by default.
But, and that is a BIG but, you also need to understand what you need to do for ldconfig for the proper setup of libfoo.so, libfoo.so.$MAJOR and so on. I taught myself that many moons ago from a Linux HOWTO.
If and when that is setup right, you can link it to R via Rcpp. Otherwise maybe stick with system libraries, or package-local static libraries. That approach will also make your package more portable.
The problem was I am consumming external libs, and I must compile it and execute ldconfig before compile my R library.

CGAL-bindings compilation

I'm trying to install CGAL-binding for Python on Ubuntu 14.
I installed CGAL as at the example in "INSTALL.md" file of CGAL github repository named "how to build the library in Release". As the next step I tried to install CGAL-binding as Full example https://github.com/CGAL/cgal-swig-bindings/wiki/Installation. But
> cmake -DCGAL_DIR=/usr/local/CGAL -DBUILD_JAVA=OFF -DPYTHON_OUTDIR_PREFIX=../../examples/python ../..
> make -j 4
causes errors from the log.
I didn't change anything in src files, but these errors point to them. How can I fix it?