From 3065219cc12ed83e090b58f8f45dd0e4cde46625 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Tue, 12 May 2020 17:07:06 -0700 Subject: [PATCH] Changes related to the release binaries requiring Visual C++ 2019 runtime (#3871) --- BUILD.md | 3 ++- README.md | 2 ++ cmake/CMakeLists.txt | 6 ------ cmake/onnxruntime_providers.cmake | 3 --- docs/Python_Dev_Notes.md | 4 +++- onnxruntime/python/_pybind_state.py | 13 ++++++++++++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/BUILD.md b/BUILD.md index 84ac601e8e..d4674f9372 100644 --- a/BUILD.md +++ b/BUILD.md @@ -129,7 +129,8 @@ The complete list of build options can be found by running `./build.sh (or .\bui ### CUDA #### Pre-Requisites * Install [CUDA](https://developer.nvidia.com/cuda-toolkit) and [cuDNN](https://developer.nvidia.com/cudnn) - * ONNX Runtime is built and tested with CUDA 10.0 and cuDNN 7.6 using the Visual Studio 2017 14.11 toolset (i.e. Visual Studio 2017 v15.3). CUDA versions from 9.1 up to 10.1, and cuDNN versions from 7.1 up to 7.4 should also work with Visual Studio 2017. + * ONNX Runtime is built and tested with CUDA 10.1 and cuDNN 7.6 using the Visual Studio 2019 14.12 toolset (i.e. Visual Studio 2019 v16.5). + ONNX Runtime can also be built with CUDA versions from 9.1 up to 10.1, and cuDNN versions from 7.1 up to 7.4. * The path to the CUDA installation must be provided via the CUDA_PATH environment variable, or the `--cuda_home parameter` * The path to the cuDNN installation (include the `cuda` folder in the path) must be provided via the cuDNN_PATH environment variable, or `--cudnn_home parameter`. The cuDNN path should contain `bin`, `include` and `lib` directories. * The path to the cuDNN bin directory must be added to the PATH environment variable so that cudnn64_7.dll is found. diff --git a/README.md b/README.md index 30a730beab..0eba37a5bb 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ These system requirements must be met for using the compiled binaries. * Follow similar procedure to configure other locales on other platforms. #### Default CPU +* Requires [Visual C++ 2019 runtime](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) * ONNX Runtime binaries in the CPU packages use OpenMP and depend on the library being available at runtime in the system. * For Windows, **OpenMP** support comes as part of VC runtime. It is also available as redist packages: @@ -140,6 +141,7 @@ system. * For Linux, the system must have **libgomp.so.1** which can be installed using `apt-get install libgomp1`. #### Default GPU (CUDA) +* Requires [Visual C++ 2019 runtime](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) * The default GPU build requires CUDA runtime libraries being installed on the system: * Version: **CUDA 10.1** and **cuDNN 7.6.5** * Version dependencies from older ONNX Runtime releases can be found in [prior release notes](https://github.com/microsoft/onnxruntime/releases). diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5db7fbc4c2..0daa23235c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -128,12 +128,6 @@ if(NOT WIN32) set(onnxruntime_ENABLE_INSTRUMENT OFF) endif() else() - check_cxx_compiler_flag(/d2FH4- HAS_D2FH4) - if (HAS_D2FH4) - message("Disabling /d2FH4") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /d2FH4-") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2FH4-") - endif() if(WINDOWS_STORE) # cmake/external/protobuf/src/google/protobuf/compiler/subprocess.cc and onnxruntime/core/platform/windows/env.cc call a bunch of Win32 APIs. # For now, we'll set the API family to desktop globally to expose Win32 symbols in headers; this must be fixed! diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index 96cc54a059..aea9dc31a0 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -207,9 +207,6 @@ if (onnxruntime_USE_CUDA) target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler -Wno-error=sign-compare>" "$<$>:-Wno-error=sign-compare>") else() - if(HAS_D2FH4) - target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler /d2FH4->") - endif() target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler /wd4127>") endif() onnxruntime_add_include_to_target(onnxruntime_providers_cuda onnxruntime_common onnxruntime_framework onnx onnx_proto protobuf::libprotobuf) diff --git a/docs/Python_Dev_Notes.md b/docs/Python_Dev_Notes.md index 13c35a8669..78804bd9f2 100644 --- a/docs/Python_Dev_Notes.md +++ b/docs/Python_Dev_Notes.md @@ -11,6 +11,8 @@ Each Python version uses a specific compiler version. In most cases, you should |2010 | 3.3,3.4 | |2008 | 2.6, 2.7, 3.0, 3.1, 3.2 | -Currently, ONNXRuntime only supports Visual C++ 2017. Therefore, Python 3.7 seems to be the best choice. +Currently, the official ONNXRuntime Python wheel (v1.3.0 onwards) hosted on PyPi requires [Visual C++ 2019 runtime ](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) installed on the target machine. + +If the Python wheel is built from source using the build toolset provided with Visual Studio 2017, it will work with the Visual C++ 2017 runtime. CPython 3.7 is distributed with a VC++ 2017 runtime. Unlike the earlier VC++ version, VC++ 2017 Runtime is binary backward compatible with VC++ 2015. Which means you could build your application with VC++ 2015 then run it with VC++ 2017 runtime. diff --git a/onnxruntime/python/_pybind_state.py b/onnxruntime/python/_pybind_state.py index c48bb8bdd0..c163fb996e 100644 --- a/onnxruntime/python/_pybind_state.py +++ b/onnxruntime/python/_pybind_state.py @@ -4,10 +4,21 @@ #-------------------------------------------------------------------------- import sys import os +import platform import warnings import onnxruntime.capi._ld_preload try: from onnxruntime.capi.onnxruntime_pybind11_state import * # noqa except ImportError as e: - warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'".format(str(e))) + warnings.warn("Cannot load onnxruntime.capi. Error: '{0}'.".format(str(e))) + + # If on Windows, check if this import error is caused by the user not installing the 2019 VC Runtime + # The VC Redist installer usually puts the VC Runtime dlls in the System32 folder + # This may not always paint the true picture as anyone building from source using VS 2017 might hit this error + # because the machine might be missing the 2019 VC Runtime but it is not actually needed in that case and the + # import error might actually be due to some other reason. + # TODO: Add a guard against False Positive error message + # As a proxy for checking if the 2019 VC Runtime is installed, we look for a specific dll only shipped with the 2019 VC Runtime + if platform.system().lower() == 'windows' and not os.path.isfile('c:\\Windows\\System32\\vcruntime140_1.dll'): + warnings.warn("Unless you have built the wheel using VS 2017, please install the 2019 Visual C++ runtime and then try again")