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

[MXNET-343]fix Mkldnn with msvc #10629

Merged
merged 17 commits into from
May 7, 2018
Merged

[MXNET-343]fix Mkldnn with msvc #10629

merged 17 commits into from
May 7, 2018

Conversation

yajiedesign
Copy link
Contributor

@yajiedesign yajiedesign commented Apr 20, 2018

Description

fix Mkldnn with msvc

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:

https://issues.apache.org/jira/browse/MXNET-343

@yajiedesign yajiedesign requested a review from szha as a code owner April 20, 2018 18:02
Jenkinsfile Outdated
@@ -358,7 +358,7 @@ try {
mkdir pkg_%BUILD_NAME%\\build
copy build_%BUILD_NAME%\\libmxnet.lib pkg_%BUILD_NAME%\\lib
copy build_%BUILD_NAME%\\libmxnet.dll pkg_%BUILD_NAME%\\build
copy build_%BUILD_NAME%\\mkldnn.dll pkg_%BUILD_NAME%\\build
copy build_%BUILD_NAME%\\3rdparty\\mkldnn\\mkldnn.dll pkg_%BUILD_NAME%\\build
copy build_%BUILD_NAME%\\libiomp5md.dll pkg_%BUILD_NAME%\\build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if the omp and mklml are also in 3rdparty\mkldnn\

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no omp mklml is in the root path.i am copy it in cmake,
the problem is that I can't figure out the location of mkldnn

Copy link
Contributor

@xinyu-intel xinyu-intel Apr 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe 3rdparty\mkldnn\src\mkldnn.dll

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems 3rdparty\mkldnn\src\mkldnn.dll is right but still some deps are missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,I don't know what is missing.Maybe msvcrt120.dll.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need some one login and look at it with depends.

CMakeLists.txt Outdated
@@ -18,8 +18,8 @@ mxnet_option(USE_CUDNN "Build with cudnn support" ON) # one could se
mxnet_option(USE_SSE "Build with x86 SSE instruction support" ON)
mxnet_option(USE_LAPACK "Build with lapack support" ON IF NOT MSVC)
mxnet_option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON)
mxnet_option(USE_MKLML_MKL "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND UNIX AND (NOT APPLE))
mxnet_option(USE_MKLDNN "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND UNIX AND (NOT APPLE))
mxnet_option(USE_MKLML_MKL "Use MKLDNN variant of MKL (if MKL found)" OFF IF (NOT APPLE))
Copy link
Contributor

@marcoabreu marcoabreu Apr 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the USE_MKL_IF_AVAILABLE argument - you're changing the default behaviour here

Jenkinsfile Outdated
@@ -311,7 +311,7 @@ try {
bat """mkdir build_vc14_gpu
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_vc14_gpu
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=All -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=Maxwell -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate this change? We're trying to cover all supported archs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only speeds up compilation speed. Theoretically, it will not affect the correctness of programs.
In fact, even if you use "ALL", it is not a test of "ALL" at the time of testing.the NV driver will only choose a suitable one.

Jenkinsfile Outdated
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_%BUILD_NAME%
set /a cores=36 * 2
jom -j 72
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the proper env variables and don't hardcode these values

@@ -125,8 +125,8 @@ endif ()
# mshadow_select_nvcc_arch_flags(out_variable)
function(mshadow_select_nvcc_arch_flags out_variable)

set(CUDA_ARCH_LIST "Auto" CACHE STRING "Select target NVIDIA GPU achitecture.")
set_property( CACHE CUDA_ARCH_LIST PROPERTY STRINGS "" "All" "Common" ${CUDA_KNOWN_GPU_ARCHITECTURES} )
set(CUDA_ARCH_LIST "" CACHE STRING "Select target NVIDIA GPU achitecture.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default behaviour change?

@@ -37,6 +38,8 @@ def find_lib_path():
logging.warning("MXNET_LIBRARY_PATH should be an absolute path, instead of: %s",
lib_from_env)
else:
if os.name == 'nt':
os.environ['PATH'] = os.path.dirname(lib_from_env) + ';' + os.environ['PATH']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please append to the end of path instead of the beginning to prevent path masking

@@ -69,6 +72,8 @@ def find_lib_path():
if len(lib_path) == 0:
raise RuntimeError('Cannot find the MXNet library.\n' +
'List of candidates:\n' + str('\n'.join(dll_path)))
if os.name == 'nt':
os.environ['PATH'] = os.path.dirname(lib_path[0]) + ';' + os.environ['PATH']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor

@marcoabreu marcoabreu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@xinyu-intel
Copy link
Contributor

@yajiedesign @marcoabreu It seems all check passed, I'll modify readme in #10613 when this pr merged. Thank you:)

Jenkinsfile Outdated
}
}
},
'Python 3: MKLDNN-GPU Win':{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm always wondering if it's necessary to test both Python 2 and 3 for all different cases? @marcoabreu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only keep one python 2 test is ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please only keep one test. Since you're testing the CPP backend, which is independent of Python, there's no need to test both versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@marcoabreu
Copy link
Contributor

@yajiedesign in future, please start using meaningful commit messages or amend your commit. The current style does not add any value to your commits and makes it hard to keep track of the changes.

Jenkinsfile Outdated
@@ -311,7 +311,7 @@ try {
bat """mkdir build_vc14_gpu
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_vc14_gpu
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=All -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_LAPACK=1 -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=Maxwell -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release -DUSE_MKL_IF_AVAILABLE=0 ${env.WORKSPACE}"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave the cuda-archs unchanged

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if(MSVC)
set(MKL_NAME "mklml_win_2018.0.2.20180127")
file(DOWNLOAD "https://github.com/intel/mkl-dnn/releases/download/v0.13/${MKL_NAME}.zip" "${CMAKE_CURRENT_BINARY_DIR}/mklml/${MKL_NAME}.zip" EXPECTED_MD5 "D7B4BD9E85BB7B85F5C956FE119A8722" SHOW_PROGRESS)
file(DOWNLOAD "https://github.com/yajiedesign/mxnet/releases/download/weekly_binary_build_v2/7z.exe" "${CMAKE_CURRENT_BINARY_DIR}/mklml/7z2.exe" EXPECTED_MD5 "E1CF766CF358F368EC97662D06EA5A4C" SHOW_PROGRESS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refrain from using private repositories

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please refrain from downloading unstable weekly builds. We want our users to only use stable and released versions.

Copy link
Contributor Author

@yajiedesign yajiedesign Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a new tag like "tools" or "utils" place this tools.

Copy link
Contributor

@marcoabreu marcoabreu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

use arc to all
remove redundant test
@yajiedesign
Copy link
Contributor Author

can we merge?

add_definitions(-DUSE_MKL=1)
add_definitions(-DCUB_MKL=1)
add_definitions(-DMXNET_USE_MKLDNN=1)
list(APPEND mxnet_LINKER_LIBS mkldnn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you are doing now. Some of the lines here are indeed not necessary.

@yajiedesign
Copy link
Contributor Author

yajiedesign commented Apr 30, 2018

Is there any problem? Can we merge? @marcoabreu @szha

Copy link
Member

@szha szha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for code changes. My cmake knowledge is limited so a second pair of eyes is appreciated.

@szha
Copy link
Member

szha commented May 3, 2018

Ping

@xinyu-intel
Copy link
Contributor

@yajiedesign seems some conflicts occured.

@xinyu-intel
Copy link
Contributor

@yajiedesign update your submodule using git submodule update --init --recursive, and then commit the new mkldnn to your repo.

@TaoLv
Copy link
Member

TaoLv commented May 5, 2018

Can you remove the mkldnn submudule change from this pr, then there is not need to fix the cpp test error.

@yajiedesign
Copy link
Contributor Author

yajiedesign commented May 5, 2018

@TaoLv no,it not need with cpp test.but it need to other.the master mkldnn(b4137dfc88e3bf5c6b62e833121802eb8c6696da) is some error with msvc.look this https://github.com/intel/mkl-dnn/blob/b4137dfc88e3bf5c6b62e833121802eb8c6696da/src/common/utils.cpp#L18 the WIN32 must is _WIN32, the new version mkldnn is fixed it.

@yajiedesign
Copy link
Contributor Author

yajiedesign commented May 5, 2018

ok.update done.wait merge.

@TaoLv
Copy link
Member

TaoLv commented May 5, 2018

OK, I see. There is another PR (#10819 ) is also trying to update the version of mkldnn submodule (maybe another version). Let's wait to see which one will be merged firstly.

@yajiedesign
Copy link
Contributor Author

@TaoLv is same version 0.14 tag 0e7ca738866d22cc700aa33b8de120b938f910d0

@ashokei
Copy link
Contributor

ashokei commented May 5, 2018

Since this issue is related to msvc, can we have this PR only have msvc change and its CI tests.

mkl-dnn version update and its CI tests are covered under MXNET-367 PR #10819 .

@piiswrong piiswrong merged commit 31016c4 into apache:master May 7, 2018
@rahul003 rahul003 mentioned this pull request May 10, 2018
4 tasks
jinhuang415 pushed a commit to jinhuang415/incubator-mxnet that referenced this pull request May 29, 2018
* fix mkldnn with msvc
add linux

* fix sum name

* jk ip

* add test

* fixed missing depend

* fix tools url
use arc to all
remove redundant test

* updata mkldnn to 0.14

* change mkldnn to v0.14

* close "-mtune=generic" with msvc, turn off test example

* up mkldnn

* change mkldnn to good v0.14 tag

* fix mklml download

* fix  MKLDNN_UTIL_FUNC.MemFormat
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* fix mkldnn with msvc
add linux

* fix sum name

* jk ip

* add test

* fixed missing depend

* fix tools url
use arc to all
remove redundant test

* updata mkldnn to 0.14

* change mkldnn to v0.14

* close "-mtune=generic" with msvc, turn off test example

* up mkldnn

* change mkldnn to good v0.14 tag

* fix mklml download

* fix  MKLDNN_UTIL_FUNC.MemFormat
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* fix mkldnn with msvc
add linux

* fix sum name

* jk ip

* add test

* fixed missing depend

* fix tools url
use arc to all
remove redundant test

* updata mkldnn to 0.14

* change mkldnn to v0.14

* close "-mtune=generic" with msvc, turn off test example

* up mkldnn

* change mkldnn to good v0.14 tag

* fix mklml download

* fix  MKLDNN_UTIL_FUNC.MemFormat
@yajiedesign yajiedesign deleted the mkldnn branch October 31, 2018 21:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants