[Bug] the latest doc about installing tvm from source code is not complete.
summary
The latest doc about installing tvm from source code cannot give enough guidance to install tvm successfully.
- It seems that tvm depends on the os system libraries like zlib/xml2. if your os does not have those libraies, the installation will failed. and also the tvm depends on cython package of python. the above dependencies are not listed on the latest doc.
- the last problem is that I need to install tvm manually to my virtual python environment else the tvm package cannot found in my python env even if the build process succeed. also the doc does not mention this.
install process
I'm trying to install tvm from soruce code according to the latest doc.(https://tvm.apache.org/docs/install/from_source.html), I encounter four issues which caused the installation failed.
issue 1
command:
cmake .. && cmake --build . --parallel 20
output:
-- LLVM links against zlib
CMake Error at /home/zyl/miniconda3/envs/tvm/share/cmake-4.1/Modules/FindPackageHandleStandardArgs.cmake:227 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
/home/zyl/miniconda3/envs/tvm/share/cmake-4.1/Modules/FindPackageHandleStandardArgs.cmake:591 (_FPHSA_FAILURE_MESSAGE)
/home/zyl/miniconda3/envs/tvm/share/cmake-4.1/Modules/FindZLIB.cmake:229 (find_package_handle_standard_args)
cmake/utils/FindLLVM.cmake:200 (find_package)
cmake/modules/LLVM.cmake:31 (find_llvm)
CMakeLists.txt:464 (include)
it seems that os did not have zlib library, I use following command install zlib for the os is ubuntu 24.04. it got solved.
sudo apt install zlib1g-dev
issue 2
continue to execute same command:
cmake .. && cmake --build . --parallel 20
output:
[100%] Built target tvm_objs
[100%] Linking CXX shared library libtvm_allvisible.so
[100%] Linking CXX shared library libtvm.so
/usr/bin/ld/usr/bin/ld: cannot find : cannot find -lxml2-lxml2: : No such file or directoryNo such file or directory
collect2: error: ld returned 1 exit status
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/tvm.dir/build.make:1624: libtvm.so] Error 1
gmake[2]: *** [CMakeFiles/tvm_allvisible.dir/build.make:1624: libtvm_allvisible.so] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:236: CMakeFiles/tvm.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:307: CMakeFiles/tvm_allvisible.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
the os did not have xml library too, I just installed xml2 and it worked the issue.
sudo apt install libxml2-dev
issue 3
continue to execute same command:
cmake .. && cmake --build . --parallel 20
output:
[100%] Built target tvm
Traceback (most recent call last):
File "/home/zyl/repos/tvm/python/setup.py", line 146, in config_cython
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/zyl/repos/tvm/python/setup.py", line 266, in <module>
ext_modules=config_cython(),
^^^^^^^^^^^^^^^
File "/home/zyl/repos/tvm/python/setup.py", line 195, in config_cython
raise RuntimeError("Cython is not installed, please pip install cython")
RuntimeError: Cython is not installed, please pip install cython
gmake[2]: *** [CMakeFiles/tvm_cython.dir/build.make:70: CMakeFiles/tvm_cython] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:371: CMakeFiles/tvm_cython.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
I use pip install cython and fixed it again.
pip install Cython
issue 4
when the build process is done, I use the following command to verify according to the doc:
(tvm) zyl@zyl-computer:~/repos/tvm$ python -c "import tvm; print(tvm.__file__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tvm
python cannot find tvm package, and I just execute the following command to manually install tvm. this behavior is not expected because doc does not say I should pip install tvm manually.
cd python && pip install -e .
now tvm had been successfully installed.
environment
os: ubuntu 24.04.2
kernle: 6.15.9-061509-generic
gcc: gcc version 14.2.0 (Ubuntu 14.2.0-4ubuntu2~24.04)
tvm git branch main commit id 49e519ecef820ab629ff735698be6578a2e92f8c
python Python 3.11.13
Sorry for late reply. Have you solved it now? The doc should be fine and you can try again:)