Windows 10: FileNotFoundError: Could not find module 'tvm.dll' (or one of its dependencies), When running `import tvm` in Python

Hi,

I tried to get tvm to work on Windows 10. Following this doc,

  1. build llvm 11.1.0 from source using Visual Studio 2019 Community Edition.
  2. add llvm’s bin to Window’s PATH.
  3. build tvm from source, following instructions from this doc with modified configs as follows.
set(USE_CUDA ON)
set(USE_LLVM "C:/Users/vagrant/llvm-project/build/Release/bin/llvm-config.exe")

other configs are defaults as defined in cmake/config.cmake. I verified, both llvm and cuda-11.5 were detected correctly.

  1. add the build directory holding tvm.dll and tvm_runtime.dll to Window’s Path i.e. tvm\build\Release.
  2. set up Python package following this section. I tried both methods.
  3. relaunch Windows Powershell and execute
PS C:\Users\vagrant> python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tvm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\vagrant\tvm-0.9dev\python\tvm\__init__.py", line 26, in <module>
    from ._ffi.base import TVMError, __version__, _RUNTIME_ONLY
  File "C:\Users\vagrant\tvm-0.9dev\python\tvm\_ffi\__init__.py", line 28, in <module>
    from .base import register_error
  File "C:\Users\vagrant\tvm-0.9dev\python\tvm\_ffi\base.py", line 71, in <module>
    _LIB, _LIB_NAME = _load_lib()
  File "C:\Users\vagrant\tvm-0.9dev\python\tvm\_ffi\base.py", line 57, in _load_lib
    lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_GLOBAL)
  File "C:\Python38\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\vagrant\tvm-0.9dev\build\Release\tvm.dll' (or one of its dependencies). Try using the full path with constructor syntax.

When import tvm, it couldn’t find tvm.dll for some reason, even though the file actually exists in the path.

I tried both tvm-0.9dev (master branch) and tvm-0.8.0, both gave the same error.

Thanks

Peeranat F.

i managed to fix the issue. Using dumpbin.exe /dependents to list all dependent dll files, it requires nvcuda.dll so i downloaded this file online and placed it next to tvm.dll then no error occurred anymore.

PS C:\Users\vagrant> python
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tvm
>>> tvm.__version__
'0.9.dev0'
>>> tvm.cuda()
cuda(0)