taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.05k stars 2.26k forks source link

taichi.Texture crashes with segmentation fault #8531

Closed femafac closed 1 week ago

femafac commented 1 month ago

Describe the bug Creating a taichi.Texture results in a segmentation fault with gpu and cpu but not with vulkan. I tried it on two different systems: ubuntu 22.04.4 with kernel 5.15.0-107 and openSUSE Tumbleweed with kernel 6.6.11-1.

To Reproduce

import taichi as ti
ti.init(arch=ti.cpu, gdb_trigger=True)       # same with ti.gpu but no problem with ti.vulkan
ti.Texture(ti.Format.rgba8, (32,32))

Log/Screenshots

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9
[Taichi] Starting on arch=x64
[E 05/21/24 14:10:33.192 30476] Received signal 11 (Segmentation fault)

***********************************
* Taichi Compiler Stack Traceback *
***********************************
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so(+0x4804d94) [0x7f73966f1d94]
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so(+0x1b34a5e) [0x7f7393a21a5e]
/lib64/libc.so.6(+0x3f190) [0x7f749a63f190]
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so: taichi::lang::Texture::~Texture()
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so: taichi::lang::Program::~Program()
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so(+0x1d1b970) [0x7f7393c08970]
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so(+0x1c11d1b) [0x7f7393afed1b]
/home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so(+0x1c11a95) [0x7f7393afea95]
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0(+0x268fa8) [0x7f749ac68fa8]
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0(+0x1aaa4d) [0x7f749abaaa4d]
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0(+0x26788c) [0x7f749ac6788c]
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0: Py_FinalizeEx
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0: Py_RunMain
/lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0: Py_BytesMain
/lib64/libc.so.6(+0x281b0) [0x7f749a6281b0]
/lib64/libc.so.6: __libc_start_main
python3(_start+0x27) [0x557f9ad3f085]

Internal error occurred. Check out this page for possible solutions:
https://docs.taichi-lang.org/docs/install

(gdb) bt
#0  0x00007f7af7900b37 in wait4 () from /lib64/libc.so.6
#1  0x00007f7af785051b in do_system () from /lib64/libc.so.6
#2  0x00007f79f38f1ddb in taichi::Logger::error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#3  0x00007f79f0c21a5e in taichi::(anonymous namespace)::signal_handler(int) ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#4  <signal handler called>
#5  0x00007f79f0c1f491 in taichi::lang::Texture::~Texture() ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#6  0x00007f79f0b7ab04 in taichi::lang::Program::~Program() ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#7  0x00007f79f0e08970 in pybind11::class_<taichi::lang::Program>::dealloc(pybind11::detail::value_and_holder&) ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#8  0x00007f79f0cfed1b in pybind11::detail::clear_instance(_object*) ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#9  0x00007f79f0cfea95 in pybind11_object_dealloc ()
   from /home/ff/.local/lib/python3.11/site-packages/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so
#10 0x00007f7af7e68fa8 in ?? () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#11 0x00007f7af7daa966 in ?? () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#12 0x00007f7af7e6788c in ?? () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#13 0x00007f7af7e56625 in Py_FinalizeEx () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#14 0x00007f7af7e62e96 in Py_RunMain () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#15 0x00007f7af7e2aa87 in Py_BytesMain () from /lib64/glibc-hwcaps/x86-64-v3/libpython3.11.so.1.0
#16 0x00007f7af78281b0 in __libc_start_call_main () from /lib64/libc.so.6
#17 0x00007f7af7828279 in __libc_start_main_impl () from /lib64/libc.so.6
#18 0x0000561d4b2b7085 in _start ()

Additional comments Output of ti diagnose:

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9

*******************************************
**      Taichi Programming Language      **
*******************************************

Docs:   https://docs.taichi-lang.org/
GitHub: https://github.com/taichi-dev/taichi/
Forum:  https://forum.taichi.graphics/

Taichi system diagnose:

python: 3.11.9 (main, Apr 08 2024, 06:18:15) [GCC]
system: linux
executable: /usr/bin/python3.11
platform: Linux-6.6.11-1-default-x86_64-with-glibc2.38
architecture: 64bit ELF
uname: uname_result(system='Linux', node='hssl1', release='6.6.11-1-default', version='#1 SMP PREEMPT_DYNAMIC Thu Jan 11 08:01:39 UTC 2024 (05ae4ad)', machine='x86_64')
locale: de_DE.UTF-8

`lsb_release` not available: [Errno 2] No such file or directory: 'lsb_release'

cpu: True
metal: False
opengl: True
cuda: True
vulkan: True

OpenGL version 4.6.0 NVIDIA 545.29.06 is supported
GL_ARB_compute_shader:                                         OK
GL_ARB_gpu_shader_int64:                                       OK
GL_NV_shader_atomic_float:                                     OK
GL_NV_shader_atomic_float64:                                   OK
GL_NV_shader_atomic_int64:                                     OK

Tue May 21 14:03:26 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.06              Driver Version: 545.29.06    CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3080        Off | 00000000:2D:00.0  On |                  N/A |
| 36%   45C    P8              61W / 340W |    723MiB / 10240MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      2007      G   /usr/bin/Xorg.bin                           411MiB |
|    0   N/A  N/A      2780      G   alacritty                                    10MiB |
|    0   N/A  N/A      4125      G   alacritty                                    10MiB |
|    0   N/A  N/A      5969      G   alacritty                                    10MiB |
|    0   N/A  N/A     18601      G   alacritty                                    10MiB |
|    0   N/A  N/A     26223      G   alacritty                                    10MiB |
|    0   N/A  N/A     28410      G   alacritty                                    10MiB |
+---------------------------------------------------------------------------------------+

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9
[Taichi] Starting on arch=x64

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9
[Taichi] Starting on arch=opengl

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9
[Taichi] Starting on arch=cuda

[Taichi] version 1.7.1, llvm 15.0.4, commit 0f143b2f, linux, python 3.11.9

42
Running example minimal ...
[Taichi] Starting on arch=x64
42.0
>>> Running time: 0.22s

Consider attaching this log when maintainers ask about system information.
>>> Running time: 3.48s
bobcao3 commented 1 week ago

Texture is only supported on Vulkan / OpenGL / Metal rn