Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
8f4dcd54
Commit
8f4dcd54
authored
Oct 08, 2017
by
Tianqi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CMAKE] Windows build instruction (#161)
parent
90554d08
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
24 deletions
+80
-24
nnvm/CMakeLists.txt
+31
-13
nnvm/docs/how_to/install.md
+18
-2
nnvm/python/nnvm/libinfo.py
+5
-5
nnvm/python/setup.py
+26
-4
No files found.
nnvm/CMakeLists.txt
View file @
8f4dcd54
...
@@ -9,16 +9,26 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
...
@@ -9,16 +9,26 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
endif
()
endif
()
include
(
cmake/Utils.cmake
)
include
(
cmake/Utils.cmake
)
if
(
EXISTS
${
CMAKE_CURRENT_BINARY_DIR
}
/config.cmake
)
include
(
${
CMAKE_CURRENT_BINARY_DIR
}
/config.cmake
)
else
()
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.cmake
)
include
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/config.cmake
)
endif
()
endif
()
# include path
# include path
include_directories
(
BEFORE
"include"
)
include_directories
(
BEFORE
"include"
)
include_directories
(
"tvm/include"
)
include_directories
(
"tvm/dlpack/include"
)
include_directories
(
"tvm/HalideIR/src"
)
set
(
nnvm
_LINKER_LIBS
""
)
set
(
NNVM
_LINKER_LIBS
""
)
set
(
NNVM_COMPILER_LINKER_LIBS
""
)
add_definitions
(
-DNNVM_EXPORTS
)
add_definitions
(
-DNNVM_EXPORTS
)
# Build a shared lib (libnnvm.so) by default
# Build a shared lib (libnnvm.so) by default
option
(
BUILD_SHARED_NNVM
"Build a shared nnvm lib"
ON
)
option
(
BUILD_SHARED_NNVM
"Build a shared nnvm lib"
ON
)
option
(
BUILD_STATIC_NNVM
"Build a static nnvm lib"
OFF
)
option
(
BUILD_STATIC_NNVM
"Build a static nnvm lib"
OFF
)
# compile
# compile
...
@@ -33,15 +43,15 @@ if(MSVC)
...
@@ -33,15 +43,15 @@ if(MSVC)
endif
(
${
flag_var
}
MATCHES
"/MD"
)
endif
(
${
flag_var
}
MATCHES
"/MD"
)
endforeach
(
flag_var
)
endforeach
(
flag_var
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/EHsc"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/EHsc"
)
find_library
(
TVM_LIB tvm
HINTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/../tvm/build/Release
HINTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/tvm/build/Release
)
message
(
STATUS
"Build with TVM libary: "
${
TVM_LIB
}
)
list
(
APPEND NNVM_COMPILER_LINKER_LIBS
${
TVM_LIB
}
)
else
(
MSVC
)
else
(
MSVC
)
include
(
CheckCXXCompilerFlag
)
include
(
CheckCXXCompilerFlag
)
check_cxx_compiler_flag
(
"-std=c++0x"
SUPPORT_CXX0X
)
check_cxx_compiler_flag
(
"-std=c++11"
SUPPORT_CXX11
)
check_cxx_compiler_flag
(
"-msse2"
SUPPORT_MSSE2
)
set
(
CMAKE_C_FLAGS
"-O3 -Wall -std=c++11 -fPIC"
)
check_cxx_compiler_flag
(
"-openmp"
SUPPORT_OPENMP
)
set
(
CMAKE_C_FLAGS
"-O3 -Wall -msse2 -Wno-unknown-pragmas -std=c++0x -fPIC"
)
if
(
SUPPORT_OPENMP
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fopenmp"
)
endif
()
set
(
CMAKE_CXX_FLAGS
${
CMAKE_C_FLAGS
}
)
set
(
CMAKE_CXX_FLAGS
${
CMAKE_C_FLAGS
}
)
endif
(
MSVC
)
endif
(
MSVC
)
...
@@ -57,11 +67,16 @@ mxnet_source_group("Source\\core" GLOB "src/core/*.cc")
...
@@ -57,11 +67,16 @@ mxnet_source_group("Source\\core" GLOB "src/core/*.cc")
mxnet_source_group
(
"Source
\\
pass"
GLOB
"src/pass/*.cc"
)
mxnet_source_group
(
"Source
\\
pass"
GLOB
"src/pass/*.cc"
)
FILE
(
GLOB_RECURSE SOURCE
file
(
GLOB_RECURSE SOURCE
src/c_api/*.cc
src/c_api/*.cc
src/core/*.cc
src/core/*.cc
src/pass/*.cc
)
src/pass/*.cc
)
file
(
GLOB_RECURSE COMPILER_SRCS
src/compiler/*.cc
src/top/*.cc
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/dmlc-core/CMakeLists.txt
)
if
(
EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/dmlc-core/CMakeLists.txt
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/dmlc-core/include
)
include_directories
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/dmlc-core/include
)
elseif
(
DMLC_CORE_PATH
)
elseif
(
DMLC_CORE_PATH
)
...
@@ -78,6 +93,9 @@ if(BUILD_STATIC_NNVM)
...
@@ -78,6 +93,9 @@ if(BUILD_STATIC_NNVM)
set_target_properties
(
nnvm_static PROPERTIES OUTPUT_NAME
"nnvm"
)
set_target_properties
(
nnvm_static PROPERTIES OUTPUT_NAME
"nnvm"
)
endif
()
endif
()
add_library
(
nnvm_compiler SHARED
${
COMPILER_SRCS
}
${
SOURCE
}
)
target_link_libraries
(
nnvm_compiler
${
NNVM_COMPILER_LINKER_LIBS
}
${
NNVM_LINKER_LIBS
}
)
if
(
INSTALL_INCLUDE_DIR
)
if
(
INSTALL_INCLUDE_DIR
)
add_custom_command
(
TARGET nnvm POST_BUILD
add_custom_command
(
TARGET nnvm POST_BUILD
COMMAND COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
COMMAND COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
...
@@ -87,10 +105,10 @@ endif()
...
@@ -87,10 +105,10 @@ endif()
# ---[ Install lib, header and docs
# ---[ Install lib, header and docs
if
(
BUILD_SHARED_NNVM
)
if
(
BUILD_SHARED_NNVM
)
install
(
TARGETS nnvm LIBRARY DESTINATION lib
)
install
(
TARGETS nnvm LIBRARY DESTINATION lib
)
endif
()
endif
()
if
(
BUILD_STATIC_NNVM
)
if
(
BUILD_STATIC_NNVM
)
install
(
TARGETS nnvm_static ARCHIVE DESTINATION lib
)
install
(
TARGETS nnvm_static ARCHIVE DESTINATION lib
)
endif
()
endif
()
install
(
DIRECTORY include DESTINATION .
)
install
(
DIRECTORY include DESTINATION .
)
install
(
DIRECTORY docs DESTINATION .
)
install
(
DIRECTORY docs DESTINATION .
)
...
...
nnvm/docs/how_to/install.md
View file @
8f4dcd54
...
@@ -34,10 +34,26 @@ The minimal building requirement is
...
@@ -34,10 +34,26 @@ The minimal building requirement is
You can edit
`make/config.mk`
to change the compile options, and then build by
You can edit
`make/config.mk`
to change the compile options, and then build by
`make`
. If everything goes well, we can go to the specific language installation section.
`make`
. If everything goes well, we can go to the specific language installation section.
### Building on Windows
NNVM support build via MSVC using cmake. The minimum required VS version is
**Visual Studio Community 2015 Update 3**
.
In order to generate the VS solution file using cmake, make sure you have a recent version of cmake added to your path.
NNVM compiler depend on tvm, please follow
[
TVM document
](
http://docs.tvmlang.org/how_to/install.html#building-on-windows
)
to build the TVM windows library. You can build the TVM in the submodule folder under nnvm.
After tvm is built, we can then start to build nnvm, using the following command.
```
bash
mkdir build
cd
build
cmake
-G
"Visual Studio 14 2015 Win64"
-DCMAKE_BUILD_TYPE
=
Release
-DCMAKE_CONFIGURATION_TYPES
=
"Release"
..
```
This will generate the VS project using the MSVC 14 64 bit generator. Open the .sln file in the build directory and build with Visual Studio.
## Python Package Installation
## Python Package Installation
The python package is located at python
The python package is located at python
.
There are several ways to install the package:
There are several ways to install the package
, in all these cases the TVM library must be present in the python env
:
1.
Set the environment variable
`PYTHONPATH`
to tell python where to find
1.
Set the environment variable
`PYTHONPATH`
to tell python where to find
the library. For example, assume we cloned
`nnvm`
on the home directory
the library. For example, assume we cloned
`nnvm`
on the home directory
...
...
nnvm/python/nnvm/libinfo.py
View file @
8f4dcd54
...
@@ -26,7 +26,7 @@ def find_lib_path():
...
@@ -26,7 +26,7 @@ def find_lib_path():
if
hasattr
(
__builtin__
,
"NNVM_LIBRARY_NAME"
):
if
hasattr
(
__builtin__
,
"NNVM_LIBRARY_NAME"
):
lib_name
=
__builtin__
.
NNVM_LIBRARY_NAME
lib_name
=
__builtin__
.
NNVM_LIBRARY_NAME
else
:
else
:
lib_name
=
"libnnvm_compiler"
lib_name
=
"
nnvm_compiler"
if
sys
.
platform
.
startswith
(
'win32'
)
else
"
libnnvm_compiler"
api_path
=
os
.
path
.
join
(
base_path
,
'../../lib/'
)
api_path
=
os
.
path
.
join
(
base_path
,
'../../lib/'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'../../build/Release/'
)
cmake_build_path
=
os
.
path
.
join
(
base_path
,
'../../build/Release/'
)
...
@@ -40,11 +40,11 @@ def find_lib_path():
...
@@ -40,11 +40,11 @@ def find_lib_path():
if
sys
.
platform
.
startswith
(
'win32'
):
if
sys
.
platform
.
startswith
(
'win32'
):
vs_configuration
=
'Release'
vs_configuration
=
'Release'
if
platform
.
architecture
()[
0
]
==
'64bit'
:
if
platform
.
architecture
()[
0
]
==
'64bit'
:
dll_path
.
append
(
os
.
path
.
join
(
curr
_path
,
'../../build'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base
_path
,
'../../build'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
curr
_path
,
'../../windows/x64'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base
_path
,
'../../windows/x64'
,
vs_configuration
))
else
:
else
:
dll_path
.
append
(
os
.
path
.
join
(
curr
_path
,
'../../build'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base
_path
,
'../../build'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
curr
_path
,
'../../windows'
,
vs_configuration
))
dll_path
.
append
(
os
.
path
.
join
(
base
_path
,
'../../windows'
,
vs_configuration
))
dll_path
=
[
os
.
path
.
join
(
p
,
'
%
s.dll'
%
lib_name
)
for
p
in
dll_path
]
dll_path
=
[
os
.
path
.
join
(
p
,
'
%
s.dll'
%
lib_name
)
for
p
in
dll_path
]
elif
sys
.
platform
.
startswith
(
'darwin'
):
elif
sys
.
platform
.
startswith
(
'darwin'
):
dll_path
=
[
os
.
path
.
join
(
p
,
'
%
s.dylib'
%
lib_name
)
for
p
in
dll_path
]
dll_path
=
[
os
.
path
.
join
(
p
,
'
%
s.dylib'
%
lib_name
)
for
p
in
dll_path
]
...
...
nnvm/python/setup.py
View file @
8f4dcd54
import
os
import
os
import
sys
import
sys
from
setuptools
import
find_packages
from
distutils.core
import
setup
from
distutils.core
import
setup
def
config_cython
():
def
config_cython
():
...
@@ -29,7 +30,28 @@ def config_cython():
...
@@ -29,7 +30,28 @@ def config_cython():
print
(
"Cython is not installed, will compile without cython module"
)
print
(
"Cython is not installed, will compile without cython module"
)
return
[]
return
[]
setup
(
# We can not import `libinfo.py` in setup.py directly since __init__.py
name
=
'nnvm'
,
# Will be invoked which introduces dependences
ext_modules
=
config_cython
()
CURRENT_DIR
=
os
.
path
.
dirname
(
__file__
)
)
libinfo_py
=
os
.
path
.
join
(
CURRENT_DIR
,
'./nnvm/libinfo.py'
)
libinfo
=
{
'__file__'
:
libinfo_py
}
exec
(
compile
(
open
(
libinfo_py
,
"rb"
)
.
read
(),
libinfo_py
,
'exec'
),
libinfo
,
libinfo
)
LIB_PATH
=
libinfo
[
'find_lib_path'
]()
_
,
LIB_NAME
=
os
.
path
.
split
(
LIB_PATH
[
0
])
__version__
=
libinfo
[
'__version__'
]
curr_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
__file__
)))
rpath
=
os
.
path
.
relpath
(
LIB_PATH
[
0
],
curr_path
)
setup
(
name
=
'nnvm'
,
version
=
__version__
,
description
=
"NNVM: Open Compiler for AI Frameworks"
,
zip_safe
=
False
,
install_requires
=
[
'numpy'
],
packages
=
find_packages
(),
url
=
'https://github.com/dmlc/nnvm'
,
include_package_data
=
True
,
data_files
=
[(
'nnvm'
,
[
rpath
])])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment