taichi-dev / taichi_elements

High-performance multi-material continuum physics engine in Taichi
MIT License
489 stars 70 forks source link

Taichi 0.6.4 not working in blender #54

Closed PavelBlend closed 4 years ago

PavelBlend commented 4 years ago

I updated taichi in blender and blender started to throw an error:

[Taichi] mode=release
[Taichi] version 0.6.4, supported archs: [cpu, opengl], commit 562e1f11, python 3.7.4
[E 05/14/20 10:13:27.773] Received signal 11 (SIGSEGV)

***********************************
* Taichi Compiler Stack Traceback *
***********************************
0x7ffe824465d1: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffe822b6e8a: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffe822be26e: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffed163c043: seh_filter_exe in ucrtbase.dll
0x7ff644f250b2: FT_Stream_OpenLZW in blender.exe
0x7ffebd9bb8f0: _C_specific_handler in VCRUNTIME140.dll
0x7ffed42611ff: _chkstk in ntdll.dll
0x7ffed422a289: RtlRaiseException in ntdll.dll
0x7ffed425fe6e: KiUserExceptionDispatcher in ntdll.dll
0x7ff6440c3045: PyInit_Main in blender.exe
0x7ff642457986: xmlLinkGetData in blender.exe
0x7ff642459504: xmlLinkGetData in blender.exe
0x7ff642458c7f: xmlLinkGetData in blender.exe
0x7ff6423f8d88: xmlLinkGetData in blender.exe
0x7ff64245723b: xmlLinkGetData in blender.exe
0x7ff64218c803: xmlLinkGetData in blender.exe
0x7ff64218b14d: xmlLinkGetData in blender.exe
0x7ff641ec5a09: xmlFileMatch in blender.exe
0x7ff641ec554a: xmlFileMatch in blender.exe
0x7ff641ec51a0: xmlFileMatch in blender.exe
0x7ff641ea2420: xmlFileMatch in blender.exe
0x7ff641ccb6b9: Unknown Function in blender.exe
0x7ff64468f5a4: FT_Stream_OpenLZW in blender.exe
0x7ffed3fa7bd4: BaseThreadInitThunk in KERNEL32.DLL
0x7ffed422ced1: RtlUserThreadStart in ntdll.dll

yuanming-hu commented 4 years ago

Thanks for reporting this! I'll take a look later today.

PavelBlend commented 4 years ago

I’ll add: this error is reproduced in windows 10.

yuanming-hu commented 4 years ago

I took a look at this on Windows and it works well without Blender. I guess debugging this together with Blender is challenging, so I'm afraid that I won't have enough time recently to fix this. I will be occupied at work before May 23, but I'll take a look after that. Meanwhile, if someone else is interested in fixing this, please go ahead.

yuanming-hu commented 4 years ago

Update: this is really hard to debug. After some painful manual testing, I confirm that v0.5.14 works but v0.5.15 doesn't. So it must be caused by some commit between two releases.

archibate commented 4 years ago

v0.5.14 works but v0.5.15 doesn't

May related to recent added OpenGL? Try disable that?

yuanming-hu commented 4 years ago

I'm not entirely sure if that's related to OpenGL (GLAD etc). A more precise binary search is needed to figure out exactly which commit leads to this behavior. Note that the error happens when we load the taichi_core.dll so there's no way to disable that at runtime (building without OpenGL sounds like a meaningful thing to try...)

EaryChow commented 4 years ago

I just found out a very interesting thing. If you have the Elements addon enabled all the time, you will have Blender crashing upon opening everytime. I tried to install taichi version 0.5.14 since @yuanming-hu said it works. After I opened Blender, I turned the Elements addon off. Then I closed Blender and I installed the latest taichi version again, then run Blender, and this time Blender opened successfully. After that, I went to the "Scripting" workspace and type "import taichi as ti" in the concole and Blender crashed again. Then I opended Blender again, this time I enabled Elements first, and turned it off right after turning it on. Then I went to the "Scripting" workspace, and type "import taichi as ti" in the concole again, this time, it did not crash, it worked. Then I wrote some testing lines (see the screenshot below), they worked. This is very interesting and I think this might help you guys in figuring out the problems so I wrote this post here.

It worked after you turn elements on and off

P.S. When I tested the "@ti.kernel" functions, it did not work. The screenshot of it is down below. It says"OSError: could not get source code". This is probably unrelated but is there any reason for this?

image

PavelBlend commented 4 years ago

Hello, @yuanming-hu

I checked this commit: 4c8dad198dae1402d7baa7eceebef29463654885 I managed to run a simulation on this commit. I managed to bake an unbounded simulation:

https://gfycat.com/boldvengefulitalianbrownbear

yuanming-hu commented 4 years ago

@EaryChow Thanks for the info. OSError: could not get source code is a known issue: Taichi just doesn't work in Python IDLE (but works in IPython).

@PavelBlend that looks really cool! Does that mean you can run Taichi in blender now?

PavelBlend commented 4 years ago

I don't know why, but blender stopped running again. How I managed to launch it last time, I did not understand. This happened by accident. I managed to do an unbounded simulation and even ran blender several times. But now I see this error:

[Taichi] mode=release
[Taichi] version 0.6.10, supported archs: [cpu, opengl], commit 1402c4e5, python 3.7.4
[E 06/18/20 07:49:00.591] Received signal 11 (SIGSEGV)

***********************************
* Taichi Compiler Stack Traceback *
***********************************
0x7ff9d31d0b11: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ff9d329b4aa: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ff9d32a288e: taichi::create_instance<taichi::Benchmark> in taichi_core.pyd
0x7ffa2695c043: seh_filter_exe in ucrtbase.dll
0x7ff62433f9e2: PyInit_aud in blender.exe
0x7ff9efe0b8f0: _C_specific_handler in VCRUNTIME140.dll
0x7ffa289e11ff: _chkstk in ntdll.dll
0x7ffa289aa289: RtlRaiseException in ntdll.dll
0x7ffa289dfe6e: KiUserExceptionDispatcher in ntdll.dll
0x7ff623496752: PyInit_manta_main in blender.exe
0x7ff621717ff6: Unknown Function in blender.exe
0x7ff62171c0b5: Unknown Function in blender.exe
0x7ff62170d454: Unknown Function in blender.exe
0x7ff6216b89f8: Unknown Function in blender.exe
0x7ff62170b67b: Unknown Function in blender.exe
0x7ff6214343f3: Unknown Function in blender.exe
0x7ff621432d3a: Unknown Function in blender.exe
0x7ff62116196e: Unknown Function in blender.exe
0x7ff62116147a: Unknown Function in blender.exe
0x7ff621160ff3: Unknown Function in blender.exe
0x7ff62113e4d0: Unknown Function in blender.exe
0x7ff620eb2269: Unknown Function in blender.exe
0x7ff623a6af74: PyInit_aud in blender.exe
0x7ffa27b07bd4: BaseThreadInitThunk in KERNEL32.DLL
0x7ffa289aced1: RtlUserThreadStart in ntdll.dll

Internal Error occurred, check this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting

EaryChow commented 4 years ago

This is no accident @PavelBlend , I can bake the same simulation as well. Like what I said, you need to make sure "Elements" is turned off when you are trying to launch blender.exe, and you can turn it on after lauching blender, also you need to remember to turn it off before you close blender as well.

If you already have "Elements" turned on and you cannot get blender to launch, I have also mentioned how I managed to get a work around as well. Install taichi 0.5.14 via pip, then launch blender, turn off "Elements" and save preferences, close blender. Then install taichi 0.6.10 back again.

PavelBlend commented 4 years ago

@yuanming-hu I installed taichi 0.6.16 and it seems the blender started to start. It seems that this problem can be closed.

yuanming-hu commented 4 years ago

Cool!