Run my own generated code using tvm runtime

I have a lot of cuda source codes generated by my own codegen tool and I want to test the correctness. Therefore, I think using tvm runtime to run my source codes is a nice start point. I read the tvm source code and hacked cuLaunchKernel and nvrtcCreatePorgram to read in my own code and launch the kernel. It works until freeing the data and I get an error like this:

Exception ignored in: <function NDArrayBase.__del__ at 0x7fffe264c200>
Traceback (most recent call last):
  File "/home/D/Project/tvm-expr/python/tvm/_ffi/_ctypes/ndarray.py", line 82, in __del__
    check_call(_LIB.TVMArrayFree(self.handle))
  File "/home/D/Project/tvm-expr/python/tvm/_ffi/base.py", line 319, in check_call
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (2) /home/D/Project/tvm-expr/build/libtvm.so(TVMArrayFree+0x30) [0x7fffe6cbd0f0]
  [bt] (1) /home/D/Project/tvm-expr/build/libtvm.so(tvm::runtime::NDArray::Internal::DefaultDeleter(tvm::runtime::Object*)+0x53) [0x7fffe6cc0b53]
  [bt] (0) /home/D/Project/tvm-expr/build/libtvm.so(tvm::runtime::CUDADeviceAPI::FreeDataSpace(DLContext, void*)+0x733) [0x7fffe6d2b0e3]
  File "/media/pku/data1/Project/tvm-expr/src/runtime/cuda/cuda_device_api.cc", line 125
CUDA: Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading: an illegal memory access was encountered
Exception ignored in: <function NDArrayBase.__del__ at 0x7fffe264c200>
Traceback (most recent call last):
  File "/home/D/Project/tvm-expr/python/tvm/_ffi/_ctypes/ndarray.py", line 82, in __del__
    check_call(_LIB.TVMArrayFree(self.handle))
  File "/home/D/Project/tvm-expr/python/tvm/_ffi/base.py", line 319, in check_call
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (2) /home/D/Project/tvm-expr/build/libtvm.so(TVMArrayFree+0x30) [0x7fffe6cbd0f0]
  [bt] (1) /home/D/Project/tvm-expr/build/libtvm.so(tvm::runtime::NDArray::Internal::DefaultDeleter(tvm::runtime::Object*)+0x53) [0x7fffe6cc0b53]
  [bt] (0) /home/D/Project/tvm-expr/build/libtvm.so(tvm::runtime::CUDADeviceAPI::FreeDataSpace(DLContext, void*)+0x733) [0x7fffe6d2b0e3]
  File "/media/pku/data1/Project/tvm-expr/src/runtime/cuda/cuda_device_api.cc", line 125
CUDA: Check failed: e == cudaSuccess || e == cudaErrorCudartUnloading: an illegal memory access was encountered

I guess I need to do more changes to tvm runtime, maybe change something about ndarry, I am not sure. What else places should I modify to gracefully achieve my aim? Could anybody give some advice?