Open nickmitchko opened 1 year ago
cc: @neozhaoliang Is this problem similar to #4936?
Yes, it's similar to #4936. Looks like libpython opens an interpreter, and since this interpreter holds the Python string inside some virtual file in memory, Taichi's ast parser cannot find that source file.
Here is a short example to reproduce this:
import taichi as ti
ti.init()
x = ti.field(int, shape=10)
@ti.kernel
def test():
for i in x:
x[i] = i
test()
Save this code to test.py
and in a python interactive shell, run
>>> with open("test.py", "r") as f:
... exec(f.read())
...
Taichi's compiler will report an error for this.
@nickmitchko I would suggest you do not run Taichi programs like this for now, and we shall discuss how to handle such user scenarios later.
Yes, it's similar to #4936. Looks like libpython opens an interpreter, and since this interpreter holds the Python string inside some virtual file in memory, Taichi's ast parser cannot find that source file.
Here is a short example to reproduce this:
import taichi as ti ti.init() x = ti.field(int, shape=10) @ti.kernel def test(): for i in x: x[i] = i test()
Save this code to
test.py
and in a python interactive shell, run>>> with open("test.py", "r") as f: ... exec(f.read()) ...
Taichi's compiler will report an error for this.
@nickmitchko I would suggest you do not run Taichi programs like this for now, and we shall discuss how to handle such user scenarios later.
Gotcha, I'd be nice to have this sort of functionality but I understand supporting libpython's source loader is engineering effort.
Describe the bug Taichi cannot find sources when using a libpython environment.
To Reproduce I've provided a sample c program using libpython that shows the error.
Main.c
/home/nmitchko/projects/taichi/taichi_nmitchko.py
Ubuntu 20.04 with gcc
Log/Screenshots