diff --git a/README.md b/README.md index c9abd82da0..cf6eece1e7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ MindSpore offers build options across multiple backends: | GPU CUDA 9.2 | Ubuntu-x86 | ✔️ | | GPU CUDA 10.1 | Ubuntu-x86 | ✔️ | | CPU | Ubuntu-x86 | ✔️ | +| CPU | Windows-x86 | ✔️ | For installation using `pip`, take `CPU` and `Ubuntu-x86` build version as an example: diff --git a/build.bat b/build.bat index 6ada61cab2..5d423720fd 100644 --- a/build.bat +++ b/build.bat @@ -21,9 +21,9 @@ IF NOT %errorlevel% == 0 ( ) IF "%1%" == "" ( - cmake --build . --target all -- -j6 + cmake --build . --target package -- -j6 ) ELSE ( - cmake --build . --target all -- -j%1% + cmake --build . --target package -- -j%1% ) IF NOT %errorlevel% == 0 ( goto run_fail diff --git a/cmake/external_libs/libtiff.cmake b/cmake/external_libs/libtiff.cmake index c9934bfaa1..4086004e33 100644 --- a/cmake/external_libs/libtiff.cmake +++ b/cmake/external_libs/libtiff.cmake @@ -8,6 +8,9 @@ else() -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") set(tiff_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -Wno-unused-result \ -Wno-unused-but-set-variable -fPIC -D_FORTIFY_SOURCE=2 -O2") + if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(tiff_CFLAGS "${tiff_CFLAGS} -Wno-int-to-pointer-cast -Wno-implicit-fallthrough -Wno-pointer-to-int-cast") + endif() endif() set(tiff_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") diff --git a/cmake/external_libs/opencv.cmake b/cmake/external_libs/opencv.cmake index 1c40769f62..b4f8d55a9e 100644 --- a/cmake/external_libs/opencv.cmake +++ b/cmake/external_libs/opencv.cmake @@ -5,6 +5,8 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") + set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-attributes -Wno-unknown-pragmas") + set(opencv_CXXFLAGS "${opencv_CXXFLAGS} -Wno-unused-value -Wno-implicit-fallthrough") else() set(opencv_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") set(opencv_CFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") @@ -28,6 +30,7 @@ if (WIN32) -DBUILD_opencv_apps=OFF -DCMAKE_SKIP_RPATH=TRUE -DBUILD_opencv_python3=OFF + -DBUILD_opencv_videoio=OFF -DWITH_FFMPEG=OFF -DWITH_TIFF=ON -DBUILD_TIFF=OFF diff --git a/cmake/package.cmake b/cmake/package.cmake index d04efca085..7d1fdc6d8a 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -30,9 +30,18 @@ include(CPack) # set install path set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries") set(INSTALL_PY_DIR ".") -set(INSTALL_LIB_DIR "lib") set(INSTALL_BASE_DIR ".") +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(INSTALL_LIB_DIR ".") + set(onednn_LIBPATH ${onednn_LIBPATH}/../bin/) + set(glog_LIBPATH ${glog_LIBPATH}/../bin/) + set(opencv_LIBPATH ${opencv_LIBPATH}/../bin/) + set(jpeg_turbo_LIBPATH ${jpeg_turbo_LIBPATH}/../bin/) +else () + set(INSTALL_LIB_DIR "lib") +endif () + # set package files install( TARGETS _c_expression @@ -80,7 +89,7 @@ if (ENABLE_CPU) elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin") file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/libdnnl*${CMAKE_SHARED_LIBRARY_SUFFIX}*) elseif (CMAKE_SYSTEM_NAME MATCHES "Windows") - file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.lib) + file(GLOB_RECURSE DNNL_LIB_LIST ${onednn_LIBPATH}/dnnl.dll) endif () install( FILES ${DNNL_LIB_LIST} @@ -140,6 +149,18 @@ if (NOT ENABLE_GE) endif () endif () +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH) + file(GLOB CXX_LIB_LIST ${CXX_DIR}/*.dll) + file(GLOB JPEG_LIB_LIST ${jpeg_turbo_LIBPATH}/*.dll) + file(GLOB SQLITE_LIB_LIST ${sqlite_LIBPATH}/*.dll) + install( + FILES ${CXX_LIB_LIST} ${JPEG_LIB_LIST} ${SQLITE_LIB_LIST} + DESTINATION ${INSTALL_LIB_DIR} + COMPONENT mindspore + ) +endif () + # set python files file(GLOB MS_PY_LIST ${CMAKE_SOURCE_DIR}/mindspore/*.py) install( diff --git a/mindspore/ccsrc/CMakeLists.txt b/mindspore/ccsrc/CMakeLists.txt index c99809f90f..77008aee5f 100644 --- a/mindspore/ccsrc/CMakeLists.txt +++ b/mindspore/ccsrc/CMakeLists.txt @@ -533,5 +533,13 @@ endif() if(ENABLE_MINDDATA) add_subdirectory(mindrecord) - add_subdirectory(dataset) + if (WIN32) + set(_md_tmp_CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) + set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O0 -Wl,--allow-shlib-undefined -DHALF_ENABLE_CPP11_USER_LITERALS=0") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_FORTIFY_SOURCE=2") + add_subdirectory(dataset) + set(CMAKE_CXX_FLAGS_RELEASE ${_md_tmp_CMAKE_CXX_FLAGS_RELEASE}) + else() + add_subdirectory(dataset) + endif() endif() diff --git a/mindspore/ops/_op_impl/__init__.py b/mindspore/ops/_op_impl/__init__.py index 76444881cc..65a12cd73c 100644 --- a/mindspore/ops/_op_impl/__init__.py +++ b/mindspore/ops/_op_impl/__init__.py @@ -14,8 +14,10 @@ # ============================================================================ """Operators info register.""" -from .akg.gpu import * -from .tbe import * +import platform from .aicpu import * +if "Windows" not in platform.system(): + from .akg.gpu import * + from .tbe import * __all__ = [] diff --git a/setup.py b/setup.py index 221c6dc4f2..82e6d70fcc 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ """setup package.""" import os import stat +import platform from setuptools import setup, find_packages from setuptools.command.egg_info import egg_info @@ -97,6 +98,8 @@ required_package = [ package_data = { '': [ '*.so*', + '*.pyd', + '*.dll', 'lib/*.so*', 'lib/*.a', '.commit_id', @@ -111,6 +114,9 @@ def update_permissions(path): Args: path (str): Target directory path. """ + if platform.system() == "Windows": + return + for dirpath, dirnames, filenames in os.walk(path): for dirname in dirnames: dir_fullpath = os.path.join(dirpath, dirname) diff --git a/third_party/securec/CMakeLists.txt b/third_party/securec/CMakeLists.txt index b2f29c488b..b195cc9555 100644 --- a/third_party/securec/CMakeLists.txt +++ b/third_party/securec/CMakeLists.txt @@ -1,5 +1,5 @@ SET(CMAKE_BUILD_TYPE "Debug") -if (WIN32) +if (CMAKE_SYSTEM_NAME MATCHES "Windows") SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer") else() SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='") @@ -8,8 +8,8 @@ SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarat set(CMAKE_EXPORT_COMPILE_COMMANDS ON) #add flags -if (WIN32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") +if (CMAKE_SYSTEM_NAME MATCHES "Windows") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Wno-attributes") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror") endif()