Problem on get_started.py

Hi, I want to run tutorial/get_stared.py with llvm/cuda.
but I got a problem, the following error:

Check failed: bf != nullptr Target cuda is not enabled

When I was googling, it means that cuda is not enabled.
But I’m sure cuda is installed and cmake is also set.

nvidia-smi, nvidia-settings are doing well and cuda sample is also working.

/usr/local/cuda-10.0/samples/1_Utilities/deviceQuery ()$ ./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)
   .......
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.0, CUDA Runtime Version = 10.0, NumDevs = 1
Result = PASS

This is my build/config.cmake,

set(USE_CUDA ON)
...
set(USE_LLVM /home/jenny/llvm/clang+llvm/bin/llvm-config)

and result of “cmake …” (before the build, make clean was also performed)

$ cmake ..
-- Build with RPC support...
-- Build with Graph runtime support...
-- Build VTA runtime with target: sim
-- Found CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
-- Found CUDA_CUDA_LIBRARY=/usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so
-- Found CUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so
-- Found CUDA_NVRTC_LIBRARY=/usr/local/cuda/lib64/libnvrtc.so
-- Found CUDA_CUDNN_LIBRARY=/home/jenny/Downloads/yes/lib/libcudnn.so
-- Found CUDA_CUBLAS_LIBRARY=/usr/local/cuda/lib64/libcublas.so
-- Build with CUDA support
-- Use llvm-config=/home/jenny/llvm/clang+llvm/bin/llvm-config
-- /home/jenny/llvm/clang+llvm/include
-- Found LLVM_INCLUDE_DIRS=/home/jenny/llvm/clang+llvm/include
-- Found LLVM_DEFINITIONS= -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Found TVM_LLVM_VERSION=60
-- Build with LLVM 
-- Set TVM_LLVM_VERSION=60
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jenny/tvm/tvm/build

The following is the error message.

<class 'tvm.tensor.Tensor'>
Traceback (most recent call last):
  File "get_started.py", line 118, in <module>
    fadd = tvm.build(s, [A, B, C], tgt, target_host=tgt_host, name="myadd")
  File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/build_module.py", line 584, in build
    fhost, mdev = _build_for_device(flist, tar, target_host)
  File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/build_module.py", line 451, in _build_for_device
    mdev = codegen.build_module(fdevice, str(target)) if fdevice else None
  File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/codegen.py", line 20, in build_module
    return _Build(lowered_func, target)
  File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/_ffi/_ctypes/function.py", line 185, in __call__
    ctypes.byref(ret_val), ctypes.byref(ret_tcode)))
  File "/home/jenny/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/_ffi/base.py", line 72, in check_call
    raise TVMError(py_str(_LIB.TVMGetLastError()))
tvm._ffi.base.TVMError: [10:40:20] /home/jenny/tvm/src/codegen/codegen.cc:27: Check failed: bf != nullptr Target cuda is not enabled

Can you help me?

Never mind, but did you install(or setup) after build with CUDA ?

Yes, I did…
I reopened the terminal, then deleted the tvm git and clone again.
Although the cmake … result is slightly different as below,
The results of the tutorial get_started.py still cause errors…

Check failed: bf != nullptr Target cuda is not enabled

-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SUPPORT_CXX11
-- Performing Test SUPPORT_CXX11 - Success
-- Build with RPC support...
-- Build with Graph runtime support...
-- Build VTA runtime with target: sim
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
-- Found CUDA_CUDA_LIBRARY=/usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so
-- Found CUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so
-- Found CUDA_NVRTC_LIBRARY=/usr/local/cuda/lib64/libnvrtc.so
-- Found CUDA_CUDNN_LIBRARY=/home/jenny/Downloads/yes/lib/libcudnn.so
-- Found CUDA_CUBLAS_LIBRARY=/usr/local/cuda/lib64/libcublas.so
-- Build with CUDA support
-- Use llvm-config=/home/jenny/llvm/clang+llvm/bin/llvm-config
-- /home/jenny/llvm/clang+llvm/include
-- Found LLVM_INCLUDE_DIRS=/home/jenny/llvm/clang+llvm/include
-- Found LLVM_DEFINITIONS= -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Found TVM_LLVM_VERSION=60
-- Build with LLVM 
-- Set TVM_LLVM_VERSION=60
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jenny/tvm/tvm/build

Thanks you @srkreddy1238 !
I solved the problem with tvm package installation method 2.
Before that, I used method 1.

# install tvm package for the current user
# NOTE: if you installed python via homebrew, --user is not needed during installaiton
#       it will be automatically installed to your user directory.
#       providing --user flag may trigger error during installation in such case.
export MACOSX_DEPLOYMENT_TARGET=10.9  # This is required for mac to avoid symbol conflicts with libstdc++
cd python; python setup.py install --user; cd ..
cd topi/python; python setup.py install --user; cd ../..
cd nnvm/python; python setup.py install --user; cd ../..
1 Like