Taichi: [misc] Importing matplotlib.pyplot before importing taichi will be fault on OSX

Created on 16 May 2020  路  5Comments  路  Source: taichi-dev/taichi

Describe the bug

Importing matplotlib.pyplot before importing taichi will be fault on OSX.

I found this bug.

Could you check it?

snippets to reproduce bugs and logs

Environments

  • OS: OSX Catalina 10.15.4
  • Python 3.7.0 64-bit (using poetry)
  • taichi: 0.6.4
  • matplotlib: 3.2.1

Import matplotlib after taichi

  • snippets
import taichi as ti
import matplotlib.pyplot as plt # changed here

pixels = ti.var(dt=ti.f32, shape=(400, 200))

@ti.kernel
def fill():
    for i, j in pixels:
        pixels[i, j] = i * j

fill()
  • Logs
[Taichi] mode=release
[Taichi] version 0.6.4, supported archs: [cpu, metal], commit 562e1f11, python 3.7.0
objc[47064]: Class View is implemented in both ?? (0x7fd6fb58b8e0) and /Users/berry/Library/Caches/pypoetry/virtualenvs/taichi-snippets-lZeOq7r2-py3.7/lib/python3.7/site-packages/matplotlib/backends/_macosx.cpython-37m-darwin.so (0x120eb4820). One of the two will be used. Which one is undefined.

This snippets will work correctly.


Import matplotlib before taichi

  • snippets
import matplotlib.pyplot as plt
import taichi as ti # changed here

pixels = ti.var(dt=ti.f32, shape=(400, 200))

@ti.kernel
def fill():
    for i, j in pixels:
        pixels[i, j] = i * j

fill()
  • Logs
[Taichi] mode=release
[E 05/16/20 17:40:29.846] Received signal 11 (Segmentation fault: 11)



                            * Taichi Core - Stack Traceback *                             
==========================================================================================
|                       Module |  Offset | Function                                      |
|----------------------------------------------------------------------------------------|
*               taichi_core.so |     324 | taichi::signal_handler(int)                   |
*     libsystem_platform.dylib |      29 | (null)                                        |
*                          ??? |   26350 | (null)                                        |
*               taichi_core.so |      94 | initView()                                    |
*                          ??? | 203506147 | (null)                                      |
*                          ??? | 203507182 | (null)                                      |
*                          ??? | 203485195 | (null)                                      |
*                          ??? | 203477012 | (null)                                      |
*                          ??? | 203477172 | (null)                                      |
*                          ??? | 203419184 | (null)                                      |
*                          ??? | 203460091 | (null)                                      |
*                libdyld.dylib |     171 | (null)                                        |
*                       python |     134 | (null)                                        |
*                       python |     494 | (null)                                        |
*                       python |     220 | (null)                                        |
*                       python |     122 | (null)                                        |
*                       python |      65 | (null)                                        |
*                       python |   46177 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     195 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45215 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45065 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     248 | (null)                                        |
*                       python |     243 | (null)                                        |
*                       python |    3600 | (null)                                        |
*                       python |   36611 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     347 | (null)                                        |
*                       python |     122 | (null)                                        |
*                       python |      65 | (null)                                        |
*                       python |   46177 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     195 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45215 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45065 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     248 | (null)                                        |
*                       python |     243 | (null)                                        |
*                       python |    3600 | (null)                                        |
*                       python |   36611 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     347 | (null)                                        |
*                       python |     122 | (null)                                        |
*                       python |      65 | (null)                                        |
*                       python |   46177 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     195 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45215 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45065 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     248 | (null)                                        |
*                       python |     243 | (null)                                        |
*                       python |    3600 | (null)                                        |
*                       python |   36611 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     347 | (null)                                        |
*                       python |     122 | (null)                                        |
*                       python |      65 | (null)                                        |
*                       python |   46177 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     195 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45215 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45065 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     181 | (null)                                        |
*                       python |   45705 | (null)                                        |
*                       python |     120 | (null)                                        |
*                       python |     248 | (null)                                        |
*                       python |     243 | (null)                                        |
*                       python |    3600 | (null)                                        |
*                       python |   36611 | (null)                                        |
*                       python |     418 | (null)                                        |
*                       python |     256 | (null)                                        |
*                       python |     388 | (null)                                        |
*                       python |    9148 | (null)                                        |
*                       python |     142 | (null)                                        |
*                libdyld.dylib |       1 | (null)                                        |
==========================================================================================

This snippets won't work.

Could you check it?

regards,

mac potential bug

All 5 comments

I also have encountered the same bug on OSX, rearranging the imports have solved the issue

I can probably take a look. My current guess is that there seems to be a conflict in the GUI system..

See https://stackoverflow.com/a/30582486/12003165

Hi -- 0.6.5 should have solved this problem now. Could you upgrade taichi and verify if it works? Thx

Hi, I tried now and it looks fine!
Thank you for your great work!

Great thanks!

Was this page helpful?
0 / 5 - 0 ratings