From 7180e7bae381b06978d7e5d34f223c5be2a56f8a Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Fri, 20 Nov 2020 20:12:04 -0500 Subject: [PATCH] [DOCS] Improve windows build instruction via conda (#6944) --- cmake/config.cmake | 9 +++--- conda/build-environment.yaml | 4 ++- docs/install/from_source.rst | 57 ++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/cmake/config.cmake b/cmake/config.cmake index 6a3ace2c9283..8ed06b26de5e 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -113,15 +113,16 @@ set(USE_MICRO_STANDALONE_RUNTIME OFF) # # Possible values: # - ON: enable llvm with cmake's find search -# - OFF: disable llvm +# - OFF: disable llvm, note this will disable CPU codegen +# which is needed for most cases # - /path/to/llvm-config: enable specific LLVM when multiple llvm-dev is available. -set(USE_LLVM OFF) +set(USE_LLVM ON) #--------------------------------------------- # Contrib libraries #--------------------------------------------- # Whether to build with BYODT software emulated posit custom datatype -# +# # Possible values: # - ON: enable BYODT posit, requires setting UNIVERSAL_PATH # - OFF: disable BYODT posit @@ -234,7 +235,7 @@ set(USE_TENSORRT_RUNTIME OFF) # Whether use VITIS-AI codegen set(USE_VITIS_AI OFF) - + # Build ANTLR parser for Relay text format # Possible values: # - ON: enable ANTLR by searching default locations (cmake find_program for antlr4 and /usr/local for jar) diff --git a/conda/build-environment.yaml b/conda/build-environment.yaml index 600933fc18b3..31b39bfafcd0 100644 --- a/conda/build-environment.yaml +++ b/conda/build-environment.yaml @@ -15,13 +15,15 @@ # specific language governing permissions and limitations # under the License. -# Build environment. +# Build environment that can be used to build tvm. name: tvm-build +# The conda channels to lookup the dependencies channels: - anaconda - conda-forge +# The packages to install to the environment dependencies: - conda-build - git diff --git a/docs/install/from_source.rst b/docs/install/from_source.rst index 2bb6e551b1a0..f329e9f7e6b9 100644 --- a/docs/install/from_source.rst +++ b/docs/install/from_source.rst @@ -90,7 +90,7 @@ The configuration of TVM can be modified by `config.cmake`. you want to build for (OpenCL, RCOM, METAL, VULKAN, ...). - To help with debugging, ensure the embedded graph runtime and debugging functions are enabled with ``set(USE_GRAPH_RUNTIME ON)`` and ``set(USE_GRAPH_RUNTIME_DEBUG ON)`` -- TVM optionally depends on LLVM. LLVM is required for CPU codegen that needs LLVM. +- TVM requires LLVM for for CPU codegen. We highly recommend you to build with the LLVM support on. - LLVM 4.0 or higher is needed for build with LLVM. Note that version of LLVM from default apt may lower than 4.0. - Since LLVM takes long time to build from source, you can download pre-built version of LLVM from @@ -102,7 +102,7 @@ The configuration of TVM can be modified by `config.cmake`. - You can also use `LLVM Nightly Ubuntu Build `_ - Note that apt-package append ``llvm-config`` with version number. - For example, set ``set(LLVM_CONFIG llvm-config-4.0)`` if you installed 4.0 package + For example, set ``set(USE_LLVM llvm-config-10)`` if you installed LLVM 10 package - We can then build tvm and related libraries. @@ -122,27 +122,58 @@ The configuration of TVM can be modified by `config.cmake`. If everything goes well, we can go to :ref:`python-package-installation` +.. _build-with-conda: + +Building with a Conda Environment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Conda is a very handy way to the necessary obtain dependencies needed for running TVM. +First, follow the `conda's installation guide `_ +to install miniconda or anaconda if you do not yet have conda in your system. Run the following command in a conda environment: + +.. code:: bash + + # Create a conda environment with the dependencies specified by the yaml + conda env create --file conda/build-environment.yaml + # Activate the created environment + conda activate tvm-build + +The above command will install all necessary build dependencies such as cmake and LLVM. You can then run the standard build process in the last section. + +If you want to use the compiled binary outside the conda environment, +you can set LLVM to static linking mode ``set(USE_LLVM "llvm-config --link-static")``. +In this way, the resulting library won't depend on the dynamic LLVM libraries in the conda environment. + +The above instructions show how to use conda to provide the necessary build dependencies to build libtvm. +If you are already using conda as your package manager and wish to directly build and install tvm as a conda package, you can follow the instructions below: + +.. code:: bash + + conda build --output-folder=conda/pkg conda/recipe + # Run conda/build_cuda.sh to build with cuda enabled + conda install tvm -c ./conda/pkg + Building on Windows ~~~~~~~~~~~~~~~~~~~ - -TVM 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 and then from the TVM directory: +TVM support build via MSVC using cmake. You will need to ontain a visual studio compiler. +The minimum required VS version is **Visual Studio Community 2015 Update 3**. +We recommend following :ref:`build-with-conda` to obtain necessary dependencies and +get an activated tvm-build environment. Then you can run the following command to build .. code:: bash - mkdir build - cd build - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" .. + mkdir build + cd build + cmake -A x64 -Thost=x64 .. + cd .. -Starting with Visual Studio 2019 the architecture is specified differently so use this command +The above command generates the solution file under the build directory. +You can then run the following command to build .. code:: bash - cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" .. + cmake --build build --config Release -- /m -This will generate the VS project using the MSVC 64 bit generator. -Open the .sln file in the build directory and build with Visual Studio. -In order to build with LLVM in windows, you will need to build LLVM from source. Building ROCm support ~~~~~~~~~~~~~~~~~~~~~