Skip to content

Commit

Permalink
[DOCS] Improve windows build instruction via conda (apache#6944)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored and trevor-m committed Dec 4, 2020
1 parent 306277c commit 7180e7b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
9 changes: 5 additions & 4 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion conda/build-environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 44 additions & 13 deletions docs/install/from_source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -102,7 +102,7 @@ The configuration of TVM can be modified by `config.cmake`.
- You can also use `LLVM Nightly Ubuntu Build <https://apt.llvm.org/>`_

- 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.

Expand All @@ -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 <https://docs.conda.io/projects/conda/en/latest/user-guide/install/>`_
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
~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 7180e7b

Please sign in to comment.