Internal Error occurred

An internal error occurred when I running the code below in Linux.

import taichi as ti
ti.init()
n = ti.var(ti.i32, shape = ())
@ti.kernel
def add():
	n[None] = 0
	for i in range(10):
		n[None] = 0
	n[None] = 0
add()
print('ok')

I am not quite sure whether I have some undefined behavior in my code or it is a bug in compiler.
Here is the error message.

[Taichi] mode=release
[Taichi] version 0.6.15, llvm 8.0.1, commit ee0281f6, python 3.8.3

*******************************************
**      Taichi Programming Language      **
*******************************************
[E 07/03/20 17:41:11.109] [taichi/common/task.h:taichi::ImplementationHolder_Task::create@30] Implementation [task::test.py] not found!


***********************************
* Taichi Compiler Stack Traceback *
***********************************
    0x7ffb149590c1: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb14a173fa: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb147d9a81: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb147cb353: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb147d1588: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb147c6c26: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb147de9b3: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb208f8584: PyCFunction_Call in python38.dll
0x7ffb20917706: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2091143f: PyFunction_Vectorcall in python38.dll
0x7ffb209a8058: PyFloat_GetInfo in python38.dll
0x7ffb208fb129: PyTuple_New in python38.dll
0x7ffb209167b8: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2090f805: PyDict_GetItem in python38.dll
0x7ffb20914d16: PyEval_EvalFrameDefault in python38.dll
0x7ffb2091135d: PyFunction_Vectorcall in python38.dll
0x7ffb208df4f2: PyVectorcall_Call in python38.dll
0x7ffb208df383: PySequence_GetItem in python38.dll
0x7ffb20918119: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2091143f: PyFunction_Vectorcall in python38.dll
0x7ffb208e91f5: PyObject_FastCallDict in python38.dll
0x7ffb209d2e11: PyObject_Call_Prepend in python38.dll
0x7ffb209d2d81: PyDescr_NewGetSet in python38.dll
0x7ffb20917706: PyEval_EvalFrameDefault in python38.dll
0x7ffb209142ce: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2097b3c3: PyEval_EvalCodeEx in python38.dll
0x7ffb2097b321: PyEval_EvalCode in python38.dll
0x7ffb2097a451: PyArena_New in python38.dll
0x7ffb2097a35b: PyArena_New in python38.dll
0x7ffb20914205: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2091654b: PyEval_EvalFrameDefault in python38.dll
0x7ffb2090fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb2091143f: PyFunction_Vectorcall in python38.dll
0x7ffb208df4f2: PyVectorcall_Call in python38.dll
0x7ffb208ddb35: PyObject_Call in python38.dll
0x7ffb20a00da5: PyThreadState_Swap in python38.dll
0x7ffb20944602: Py_RunMain in python38.dll
0x7ffb2094450d: Py_RunMain in python38.dll
0x7ff7e8a63d7e: Unknown Function in python3.8.exe
0x7ff7e8a67574: Unknown Function in python3.8.exe
0x7ffb63297bd4: BaseThreadInitThunk in KERNEL32.DLL
0x7ffb642ece51: RtlUserThreadStart in ntdll.dll

Internal Error occurred, check this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1008.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\__main__.py", line 2, in <module>
    main()
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\main.py", line 948, in main
    return cli()
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\main.py", line 27, in wrapper
    result = func(*args, **kwargs)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\main.py", line 95, in __call__
    return getattr(self, args.command)(sys.argv[2:])
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\main.py", line 925, in run
    task = ti.Task(args.taskname)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi
\core\unit.py", line 16, in new_init
    self.c = getattr(taichi.ti_core, 'create_' + unit_name)(name)
RuntimeError: [taichi/common/task.h:taichi::ImplementationHolder_Task::create@30] Implementation [task::test.py] not found!

Did you run ti run test.py in shell?
You should run python test.py instead.

I’ve tried to run this code on wsl, windows shell and mac, and tried both python -m taichi test.py and python -m taichi run test.py, but none of these works.
Can this code run correctly on your PC?

Yes, I got another error instead, which is a separate issue.

python -m taichi run test.py

python test.py

I don’t understand…
Is there any problems in this code?
Or is this a bug in Taichi compiler?
Or do i make any mistakes when I run this code?

You made a mistake in the way to run the code.
Have you used Python before? Don’t append -m taichi when running a script.

Let’s make test.py simple with just this line:

import taichi as ti

Then type this into shell:

python test.py

Then hit ENTER.


My result:

root@archlinux ~/taichi (git)-[master] # echo import taichi as ti > test.py
root@archlinux ~/taichi (git)-[master] # cat test.py
import taichi as ti
root@archlinux ~/taichi (git)-[master] # python test.py
[Taichi] mode=development
[Taichi] preparing sandbox at /tmp/taichi-e3xr84ub
[Taichi] <dev mode>, llvm 10.0.0, commit 6d03f2a0, python 3.8.3
root@archlinux ~/taichi (git)-[master] # 

I use python test.py to run this code, and here is the result.

[Taichi] mode=release
[Taichi] version 0.6.15, llvm 8.0.1, commit ee0281f6, python 3.8.3
[Taichi] Starting on arch=x64
[E 07/04/20 14:52:44.967] [offload.cpp:taichi::lang::irpass::`anonymous-namespace'::FixCrossOffloadReferences::visit_operand@445] !op->has_global_side_effect()


***********************************
* Taichi Compiler Stack Traceback *
***********************************
0x7ffb0c7790c1: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c8373fa: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7cd2c7: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7cc7be: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c5a6d81: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c60edcd: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7cc5a9: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c60edcd: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7ca46d: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7c9fd2: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c78d892: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c6af99a: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c6c0c17: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c6aec76: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c6aeaef: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c7185c2: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c6cb256: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb0c5fe9b3: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffb1d328584: PyCFunction_Call in python38.dll
0x7ffb1d329bba: PyObject_MakeTpCall in python38.dll
0x7ffb1d457141: Py_gitversion in python38.dll
0x7ffb1d30f4f2: PyVectorcall_Call in python38.dll
0x7ffb1d30db35: PyObject_Call in python38.dll
0x7ffb1d482313: Py_gitversion in python38.dll
0x7ffb1d347706: PyEval_EvalFrameDefault in python38.dll
0x7ffb1d33fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb1d34143f: PyFunction_Vectorcall in python38.dll
0x7ffb1d30f4f2: PyVectorcall_Call in python38.dll
0x7ffb1d30f383: PySequence_GetItem in python38.dll
0x7ffb1d348119: PyEval_EvalFrameDefault in python38.dll
0x7ffb1d33fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb1d34143f: PyFunction_Vectorcall in python38.dll
0x7ffb1d319260: PyObject_FastCallDict in python38.dll
0x7ffb1d402e11: PyObject_Call_Prepend in python38.dll
0x7ffb1d402d81: PyDescr_NewGetSet in python38.dll
0x7ffb1d30f3ff: PySequence_GetItem in python38.dll
0x7ffb1d348119: PyEval_EvalFrameDefault in python38.dll
0x7ffb1d33fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb1d34654b: PyEval_EvalFrameDefault in python38.dll
0x7ffb1d33fc58: PyEval_EvalCodeWithName in python38.dll
0x7ffb1d3ab3c3: PyEval_EvalCodeEx in python38.dll
0x7ffb1d3ab321: PyEval_EvalCode in python38.dll
0x7ffb1d3a9fde: PyArena_New in python38.dll
0x7ffb1d3a9f6d: PyArena_New in python38.dll
0x7ffb1d41f078: PyRun_FileExFlags in python38.dll
0x7ffb1d41e71f: PyRun_SimpleFileExFlags in python38.dll
0x7ffb1d4e724f: PyRun_AnyFileExFlags in python38.dll
0x7ffb1d491c27: Py_gitversion in python38.dll
0x7ffb1d374684: Py_RunMain in python38.dll
0x7ffb1d37450d: Py_RunMain in python38.dll
0x7ff6121c3d7e: Unknown Function in python3.8.exe
0x7ff6121c7574: Unknown Function in python3.8.exe
0x7ffb63297bd4: BaseThreadInitThunk in KERNEL32.DLL
0x7ffb642ece51: RtlUserThreadStart in ntdll.dll

Internal Error occurred, check this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting
Traceback (most recent call last):
  File "test.py", line 10, in <module>
    add()
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi\lang\kernel.py", line 528, in wrapped
    return primal(*args, **kwargs)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi\lang\kernel.py", line 460, in __call__
    return self.compiled_functions[key](*args)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\taichi\lang\kernel.py", line 424, in func__
    t_kernel()
RuntimeError: [offload.cpp:taichi::lang::irpass::`anonymous-namespace'::FixCrossOffloadReferences::visit_operand@445] !op->has_global_side_effect()

But if I delete the ninth line in the original code (see below), it works.

import taichi as ti
ti.init()
n = ti.var(ti.i32, shape = ())
@ti.kernel
def add():
	n[None] = 0
	for i in range(10):
		n[None] = 0
	#n[None] = 0
add()
print('ok')

Here is the result of the new code:

[Taichi] mode=release
[Taichi] version 0.6.15, llvm 8.0.1, commit ee0281f6, python 3.8.3
[Taichi] Starting on arch=x64
ok

I am confused about these results.

!op->has_global_side_effect()

This is a compiler bug, fixed in:

And hopefully could be released in v0.6.16 tonight.

1 个赞