taichi-dev / taichi-aot-demo

A demo illustrating how to use Taichi as an AOT shader compiler
Apache License 2.0
71 stars 16 forks source link

Link errors on ubuntu 20.04 with clang-10 #47

Open zchrissirhcz opened 1 year ago

zchrissirhcz commented 1 year ago

taichi version

I build taichi from source with latest commit 7cab180f1

* 7cab180f1 2022-10-28 | [Bug] [error] Add argument 'module' to 'warn_explicit' to show the deprecated warning (#6467)

I modified cmake options:

TI_WITH_VULKAN set to ON
TI_WITH_C_API  set to ON

Then I build with:

export CXX=/usr/bin/clang++-10
python3 setup.py install

it success.

taichi-aot-demo version

I build taichi-aot-demo with latest commit 1735a29

* 1735a29 2022-10-25 | Fix VMA usage & debug printing (#45) (HEAD -> master, origin/master, origin/HEAD) [PENGUINLIONG]

export CXX=/usr/bin/clang++-10 export TAICHI_C_API_INSTALL_DIR=/home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api

But it failed with:

...

[ 67%] Built target 3_implicit_fem
Consolidate compiler generated dependencies of target E1_hello_world_headless
Consolidate compiler generated dependencies of target E1_hello_world_glfw
Consolidate compiler generated dependencies of target E2_mpm88_headless
Consolidate compiler generated dependencies of target E2_mpm88_glfw
[ 68%] Linking CXX executable headless/E1_hello_world_headless
[ 69%] Linking CXX executable headless/E2_mpm88_headless
[ 70%] Linking CXX executable glfw/E1_hello_world_glfw
[ 70%] Linking CXX executable glfw/E2_mpm88_glfw
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E2_mpm88_headless.dir/build.make:209:headless/E2_mpm88_headless] 错误 1
make[1]: *** [CMakeFiles/Makefile2:531:CMakeFiles/E2_mpm88_headless.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E1_hello_world_headless.dir/build.make:209:headless/E1_hello_world_headless] 错误 1
make[1]: *** [CMakeFiles/Makefile2:497:CMakeFiles/E1_hello_world_headless.dir/all] 错误 2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E2_mpm88_glfw.dir/build.make:212:glfw/E2_mpm88_glfw] 错误 1
make[1]: *** [CMakeFiles/Makefile2:635:CMakeFiles/E2_mpm88_glfw.dir/all] 错误 2
make[2]: *** [CMakeFiles/E1_hello_world_glfw.dir/build.make:212:glfw/E1_hello_world_glfw] 错误 1
make[1]: *** [CMakeFiles/Makefile2:600:CMakeFiles/E1_hello_world_glfw.dir/all] 错误 2
make: *** [Makefile:136:all] 错误 2
zchrissirhcz commented 1 year ago

Also tried a clean build with customized options for taichi-aot-demo:

TI_WITH_VULKAN=OFF
TI_WITH_CPU=ON

but also fails. T_T

zchrissirhcz commented 1 year ago

I read the documentation again and find I missed the customized LLVM 10.0 installation. I'll try it again.

zchrissirhcz commented 1 year ago

I installed the customized LLVM-10 from taichi document website, prepend to my PATH env var, and export CC and CXX to clang-10 and clang++-10. With a clean rebuild of taichi and taichi-aot-demo, it still failed to link.

Details

When build taichi-aot-demo:

(base) zz@arcsoft-43% env | ag 'CC'
CC=/usr/bin/clang-10
(base) zz@arcsoft-43% env | ag 'CXX'
CXX=/usr/bin/clang++-10
(base) zz@arcsoft-43% env | ag 'TAICHI'
TAICHI_REPO_DIR=/home/zz/work/taichi
TAICHI_C_API_INSTALL_DIR=/home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api
(base) zz@arcsoft-43% which llvm-ar
/home/zz/soft/taichi-llvm-10.0.0-linux/bin/llvm-ar
(base) zz@arcsoft-43% echo $PATH
/home/zz/soft/taichi-llvm-10.0.0-linux/bin:/home/zz/.local/bin:/home/zz/soft/rr-5.5.0-dev/bin:/home/zz/soft/emacs-28.1/bin:/home/zz/.emacs.d/bin:/home/zz/soft/jdk-11.0.14+9/bin:/home/zz/.npm-global/bin:/home/zz/soft/lcov-1.15/bin:/home/zz/soft/nvim/bin:/home/zz/soft/iwyu-clang12/bin:/home/zz/lib/arctools_arcdb-v1.0.3.3/ArcDB/linux:/home/zz/soft/hisi-linux/arm-hisiv500-linux/target/bin:/home/zz/soft/doxygen-1.9.3-dev/bin:/home/zz/soft/gcc-linaro-arm-linux-gnueabihf-4.8/bin:/home/zz/soft/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:/home/zz/soft/cmake-3.24.2/bin:/home/zz/soft/vulkansdk/1.3.204.1/x86_64/bin:/usr/local/cuda-10.2/bin:/home/zz/Android/Sdk/platform-tools:/home/zz/soft/pnnx-20220418-ubuntu:/home/zz/soft/lite-xl/bin:/home/zz/.npm-global/bin:/home/zz/bin:/home/zz/soft/miniconda3/bin:/home/zz/soft/miniconda3/condabin:/home/zz/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
...
[ 67%] Linking CXX executable headless/E1_hello_world_headless
[ 68%] Linking CXX executable headless/E2_mpm88_headless
[ 69%] Linking CXX executable headless/E3_implicit_fem_headless
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E1_hello_world_headless.dir/build.make:209:headless/E1_hello_world_headless] 错误 1
make[1]: *** [CMakeFiles/Makefile2:497:CMakeFiles/E1_hello_world_headless.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E2_mpm88_headless.dir/build.make:209:headless/E2_mpm88_headless] 错误 1
make[1]: *** [CMakeFiles/Makefile2:531:CMakeFiles/E2_mpm88_headless.dir/all] 错误 2
/usr/bin/ld: /home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api/lib/libtaichi_c_api.so: undefined reference to `llvm::cfg::Update<llvm::BasicBlock*>::dump() const'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [CMakeFiles/E3_implicit_fem_headless.dir/build.make:209:headless/E3_implicit_fem_headless] 错误 1
make[1]: *** [CMakeFiles/Makefile2:565:CMakeFiles/E3_implicit_fem_headless.dir/all] 错误 2
[ 70%] Linking C static library libglfw3.a
[ 70%] Built target glfw
make: *** [Makefile:136:all] 错误 2
PENGUINLIONG commented 1 year ago

If Vulkan is all you need I recommend you to disable llvm compilation with TI_WITH_LLVM=OFF then you don't need LLVM10 anymore

zchrissirhcz commented 1 year ago

After disabling TI_WITH_LLVM, it links OK.

The running result of taichi-aot-demo shows that, E1 is OK, E2 and E3 has some error.

(base) zz@arcsoft-43% ./E1_hello_world_headless 
framework initialized
initialized!
stepped! (fps=3.44828e+07)
stepped! (fps=14.9125)
framework finalized
(base) zz@arcsoft-43% ./E2_mpm88_headless 
framework initialized
[W 10/31/22 10:40:27.068 110333] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (path not found) 2_mpm88/assets/mpm88
[W 10/31/22 10:40:27.068 110333] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:40:27.068 110333] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:40:27.129 110333] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) compute_graph
initialized!
[W 10/31/22 10:40:27.134 110333] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) compute_graph
stepped! (fps=3.33333e+07)
terminate called after throwing an instance of 'std::runtime_error'
  what():  taichi failed
zsh: abort (core dumped)  ./E2_mpm88_headless
(base) zz@arcsoft-43% ./E3_implicit_fem_headless 
framework initialized
[W 10/31/22 10:40:39.844 110360] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (path not found) 3_implicit_fem/assets/implicit_fem
[W 10/31/22 10:40:39.844 110360] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:40:39.844 110360] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
terminate called after throwing an instance of 'std::length_error'
  what():  vector::_M_default_append
zsh: abort (core dumped)  ./E3_implicit_fem_headless

The running directory is:

(base) zz@arcsoft-43% pwd
/home/zz/work/taichi-aot-demo/build/linux-x64
jim19930609 commented 1 year ago

Hi @zchrissirhcz, I pushed a PR just now to fix a similar problem with E3_implicit_fem_headless. Can you pull "master" branch of taichi-aot-demo and try again?

zchrissirhcz commented 1 year ago

@jim19930609 Hi, tested but E2 and E3 still has some error message

* 88814e9 2022-10-31 | Regenerate AOT files at build time (#49) (HEAD -> master, origin/master, origin/HEAD) [Zhanlue Yang]
(base) zz@arcsoft-43% ./E2_mpm88_headless 
framework initialized
[W 10/31/22 10:51:57.363 114035] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (path not found) 2_mpm88/assets/mpm88
[W 10/31/22 10:51:57.363 114035] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:51:57.363 114035] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:51:57.425 114035] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) compute_graph
initialized!
[W 10/31/22 10:51:57.430 114035] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) compute_graph
stepped! (fps=2.77778e+07)
terminate called after throwing an instance of 'std::runtime_error'
  what():  taichi failed
zsh: abort (core dumped)  ./E2_mpm88_headless
(base) zz@arcsoft-43% ./E3_implicit_fem_headless 
framework initialized
[W 10/31/22 10:52:01.061 114047] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (path not found) 3_implicit_fem/assets/implicit_fem
[W 10/31/22 10:52:01.061 114047] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
[W 10/31/22 10:52:01.061 114047] [taichi_core_impl.cpp:ti_set_last_error@130] C-API error: (argument null) aot_module
terminate called after throwing an instance of 'std::length_error'
  what():  vector::_M_default_append
zsh: abort (core dumped)  ./E3_implicit_fem_headless
PENGUINLIONG commented 1 year ago

You should launch the test apps in the root current directory.

zchrissirhcz commented 1 year ago

Now switched to root directory of taichi-aot-demo project, run again. It now print initialized!. But still some error ...

(base) zz@arcsoft-43% pwd
/home/zz/work/taichi-aot-demo
(base) zz@arcsoft-43% ./build/linux-x64/headless/E2_mpm88_headless 
framework initialized
initialized!
stepped! (fps=3.44828e+07)
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build/linux-x64/headless/E2_mpm88_headless
(base) zz@arcsoft-43% ./build/linux-x64/headless/E2_mpm88_headless 
framework initialized
initialized!
stepped! (fps=3.125e+07)
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build/linux-x64/headless/E2_mpm88_headless
jim19930609 commented 1 year ago

That looks weird, can you try:

  1. Make a clean build after pulling the master branch
  2. Specify your python executable with: TAICHI_C_API_INSTALL_DIR=... cmake .. -DPYTHON_EXECUTABLE=...

Have you noticed any error message while cmake is running?

zchrissirhcz commented 1 year ago

@jim19930609 I pasted the cmake configure full output in the following.

create directory

cd ~/work/taichi-aot-demo
git pull
mkdir build2  # a fresh new build
cd build2

cmake configure output

TAICHI_C_API_INSTALL_DIR=/home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api  cmake .. -DPYTHON_EXECUTABLE=/home/zz/soft/miniconda3/bin/python
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-10 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-10 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- TAICHI_C_API_INSTALL_DIR=/home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api
-- Found Vulkan: /home/zz/soft/vulkansdk/1.3.204.1/x86_64/lib/libvulkan.so (found version "1.3.204") found components: glslc glslangValidator 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found Doxygen: /home/zz/soft/doxygen-1.9.3-dev/bin/doxygen (found version "1.9.3 (225160928d545c0768842558624aa654f6fab906)") found components: doxygen 
-- Including X11 support
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- VMA_BUILD_SAMPLE = OFF
-- VMA_BUILD_SAMPLE_SHADERS = OFF
-- VMA_STATIC_VULKAN_FUNCTIONS = ON
-- VMA_DYNAMIC_VULKAN_FUNCTIONS = OFF
-- VMA_DEBUG_ALWAYS_DEDICATED_MEMORY = OFF
-- VMA_DEBUG_INITIALIZE_ALLOCATIONS = OFF
-- VMA_DEBUG_GLOBAL_MUTEX = OFF
-- VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT = OFF
-- Found Doxygen: /home/zz/soft/doxygen-1.9.3-dev/bin/doxygen (found version "1.9.3 (225160928d545c0768842558624aa654f6fab906)") found components: doxygen dot 
-- No build type selected, default to Debug
-- Found PythonInterp: /home/zz/soft/miniconda3/bin/python (found suitable version "3.10.6", minimum required is "3") 
-- Google Mock was not found - tests based on that will not build
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- GLM: Version 0.9.9.9
-- Building demo libraries:
--   1_hello_world @ headless
--   2_mpm88 @ headless
--   3_implicit_fem @ headless
--   1_hello_world @ glfw
--   2_mpm88 @ glfw
--   3_implicit_fem @ glfw
-- Found PythonInterp: /home/zz/soft/miniconda3/bin/python (found version "3.10.6") 
[I 10/31/22 11:36:03.315 125940] [vulkan_device_creator.cpp:pick_physical_device@399] Found Vulkan Device 0 (NVIDIA GeForce RTX 2080)
[I 10/31/22 11:36:03.316 125940] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:03.316 125940] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:03.316 125940] [vulkan_device_creator.cpp:create_logical_device@469] Vulkan Device "NVIDIA GeForce RTX 2080" supports Vulkan 0 version 1.3.205
[I 10/31/22 11:36:03.399 125940] [vulkan_device_creator.cpp:pick_physical_device@399] Found Vulkan Device 0 (NVIDIA GeForce RTX 2080)
[I 10/31/22 11:36:03.399 125940] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:03.399 125940] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:03.399 125940] [vulkan_device_creator.cpp:create_logical_device@469] Vulkan Device "NVIDIA GeForce RTX 2080" supports Vulkan 0 version 1.3.205
/home/zz/work/taichi/python/taichi/__init__.py:77: DeprecationWarning: ti.any_arr is deprecated. Please use ti.types.ndarray instead.
  warnings.warn(
[Taichi] version 1.3.0, llvm targets unsupported, commit 7cab180f, linux, python 3.10.6
[Taichi] Starting on arch=vulkan
[Taichi] Starting on arch=vulkan
[I 10/31/22 11:36:04.557 125963] [vulkan_device_creator.cpp:pick_physical_device@399] Found Vulkan Device 0 (NVIDIA GeForce RTX 2080)
[I 10/31/22 11:36:04.557 125963] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:04.557 125963] [vulkan_device_creator.cpp:find_queue_families@148] Async compute queue 2, graphics queue 0
[I 10/31/22 11:36:04.557 125963] [vulkan_device_creator.cpp:create_logical_device@469] Vulkan Device "NVIDIA GeForce RTX 2080" supports Vulkan 0 version 1.3.205
[Taichi] version 1.3.0, llvm targets unsupported, commit 7cab180f, linux, python 3.10.6
[Taichi] Starting on arch=vulkan
UserWarning: Taichi matrices/vectors with 12x12 > 32 entries are not suggested. Matrices/vectors will be automatically unrolled at compile-time for performance. So the compilation time could be extremely long if the matrix size is too big. You may use a field to store a large matrix like this, e.g.:
    x = ti.field(ti.f32, (12, 12)).
 See https://docs.taichi-lang.org/docs/field#matrix-size for more details.
  File "/home/zz/work/taichi-aot-demo/3_implicit_fem/assets/implicit_fem.py", line 333, in <module>
    g_init_builder.dispatch(get_matrix, sym_c2e, sym_vertices, sym_B, sym_W, sym_hes_edge, sym_hes_vert)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 48, in dispatch
    kernel_cpp = gen_cpp_kernel(kernel_fn, args)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 16, in gen_cpp_kernel
    key = kernel.ensure_compiled(*injected_args)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled
    self.materialize(key=key, args=args, arg_features=arg_features)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize
    taichi_kernel = impl.get_runtime().prog.create_kernel(
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator
    transform_tree(tree, ctx)
  File "/home/zz/work/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree
    ASTTransformer()(ctx, tree)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 760, in build_Module
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 701, in build_FunctionDef
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1263, in build_For
    return ASTTransformer.build_struct_for(ctx,
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1155, in build_struct_for
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 113, in build_Assign
    build_stmt(ctx, node.value)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 535, in build_Call
    node.ptr = func(*args, **keywords)
  File "/home/zz/work/taichi/python/taichi/lang/util.py", line 288, in wrapped
    return func(*args, **kwargs)
  File "/home/zz/work/taichi/python/taichi/lang/matrix.py", line 1052, in zero
    return Matrix([[ops_mod.cast(0, dt) for _ in range(m)]

UserWarning: Taichi matrices/vectors with 12x12 > 32 entries are not suggested. Matrices/vectors will be automatically unrolled at compile-time for performance. So the compilation time could be extremely long if the matrix size is too big. You may use a field to store a large matrix like this, e.g.:
    x = ti.field(ti.f32, (12, 12)).
 See https://docs.taichi-lang.org/docs/field#matrix-size for more details.
  File "/home/zz/work/taichi-aot-demo/3_implicit_fem/assets/implicit_fem.py", line 333, in <module>
    g_init_builder.dispatch(get_matrix, sym_c2e, sym_vertices, sym_B, sym_W, sym_hes_edge, sym_hes_vert)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 48, in dispatch
    kernel_cpp = gen_cpp_kernel(kernel_fn, args)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 16, in gen_cpp_kernel
    key = kernel.ensure_compiled(*injected_args)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled
    self.materialize(key=key, args=args, arg_features=arg_features)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize
    taichi_kernel = impl.get_runtime().prog.create_kernel(
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator
    transform_tree(tree, ctx)
  File "/home/zz/work/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree
    ASTTransformer()(ctx, tree)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 760, in build_Module
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 701, in build_FunctionDef
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1263, in build_For
    return ASTTransformer.build_struct_for(ctx,
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1155, in build_struct_for
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 121, in build_Assign
    values = node.value.ptr if is_static_assign else impl.expr_init(
  File "/home/zz/work/taichi/python/taichi/lang/util.py", line 288, in wrapped
    return func(*args, **kwargs)
  File "/home/zz/work/taichi/python/taichi/lang/impl.py", line 71, in expr_init
    return Matrix(rhs.to_list(), ndim=rhs.ndim)

UserWarning: Taichi matrices/vectors with 12x12 > 32 entries are not suggested. Matrices/vectors will be automatically unrolled at compile-time for performance. So the compilation time could be extremely long if the matrix size is too big. You may use a field to store a large matrix like this, e.g.:
    x = ti.field(ti.f32, (12, 12)).
 See https://docs.taichi-lang.org/docs/field#matrix-size for more details.
  File "/home/zz/work/taichi-aot-demo/3_implicit_fem/assets/implicit_fem.py", line 333, in <module>
    g_init_builder.dispatch(get_matrix, sym_c2e, sym_vertices, sym_B, sym_W, sym_hes_edge, sym_hes_vert)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 48, in dispatch
    kernel_cpp = gen_cpp_kernel(kernel_fn, args)
  File "/home/zz/work/taichi/python/taichi/graph/_graph.py", line 16, in gen_cpp_kernel
    key = kernel.ensure_compiled(*injected_args)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 855, in ensure_compiled
    self.materialize(key=key, args=args, arg_features=arg_features)
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 566, in materialize
    taichi_kernel = impl.get_runtime().prog.create_kernel(
  File "/home/zz/work/taichi/python/taichi/lang/kernel_impl.py", line 556, in taichi_ast_generator
    transform_tree(tree, ctx)
  File "/home/zz/work/taichi/python/taichi/lang/ast/transform.py", line 6, in transform_tree
    ASTTransformer()(ctx, tree)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 760, in build_Module
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 701, in build_FunctionDef
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1263, in build_For
    return ASTTransformer.build_struct_for(ctx,
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1155, in build_struct_for
    build_stmts(ctx, node.body)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 1474, in build_stmts
    build_stmt(ctx, stmt)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer_utils.py", line 25, in __call__
    return method(ctx, node)
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 125, in build_Assign
    ASTTransformer.build_assign_unpack(ctx, node_target, values,
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 142, in build_assign_unpack
    return ASTTransformer.build_assign_basic(ctx, node_target, values,
  File "/home/zz/work/taichi/python/taichi/lang/ast/ast_transformer.py", line 195, in build_assign_basic
    var = impl.expr_init(value)
  File "/home/zz/work/taichi/python/taichi/lang/util.py", line 288, in wrapped
    return func(*args, **kwargs)
  File "/home/zz/work/taichi/python/taichi/lang/impl.py", line 71, in expr_init
    return Matrix(rhs.to_list(), ndim=rhs.ndim)

dt=0.0075 num_substeps=3
AOT done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zz/work/taichi-aot-demo/build2
PENGUINLIONG commented 1 year ago

btw we have recently solved a compatibility issue so please ensure you are using the latest master for both repo

jim19930609 commented 1 year ago

The cmake outputs looks fine...If you've tried building libtaichi_c_api.so with the latest taichi master and the error still persists, then we have to look into the "vulkan failure" to figure out what's going on with that

zchrissirhcz commented 1 year ago

Let me check again.

repos should use latest

taichi repo:

commit b1b7fc83d3359f8518c0e66c11d2f9ccbd85f959 (HEAD -> master, origin/master, origin/HEAD)
Author: Ailing <ailzhang@users.noreply.github.com>
Date:   Sun Oct 30 20:55:24 2022 -0700

    [ci] Switch linux gpu job to use LLVM 15 (#6465)

    Issue: #6447

    ### Brief Summary

taichi-aot-demo repo:

(base) zz@arcsoft-43% git log -1
commit 88814e939791c70bb8c3010453ab9c0ed119d22e (HEAD -> master, origin/master, origin/HEAD)
Author: Zhanlue Yang <jim19930609@gmail.com>
Date:   Mon Oct 31 10:28:04 2022 +0800

    Regenerate AOT files at build time (#49)

vulkan version

(base) zz@arcsoft-43% env | ag 'VULKAN'
VULKAN_SDK=/home/zz/soft/vulkansdk/1.3.204.1/x86_64

compiler version

(base) zz@arcsoft-43% echo $CC
/usr/bin/clang-10
(base) zz@arcsoft-43% echo $CXX
/usr/bin/clang++-10
(base) zz@arcsoft-43% /usr/bin/clang-10 --version
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
(base) zz@arcsoft-43% /usr/bin/clang++-10 --version
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

cmake version

(base) zz@arcsoft-43% cmake --version
cmake version 3.24.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Python version

(base) zz@arcsoft-43% python --version
Python 3.10.6
(base) zz@arcsoft-43% which python
/home/zz/soft/miniconda3/bin/python

Build commands

build taichi

(base) zz@arcsoft-43% cd ~/work/taichi/
(base) zz@arcsoft-43% rm -rf _skbuild 
(base) zz@arcsoft-43% python setup.py install > taichi-build-log.txt 2>&1

taichi-build-log.txt

build and run taichi-aot-demo

cd ~/work/taichi-aot-demo

TAICHI_C_API_INSTALL_DIR=/home/zz/work/taichi/_skbuild/linux-x86_64-3.10/cmake-install/c_api  cmake -S . -B build3 -DPYTHON_EXECUTABLE=/home/zz/soft/miniconda3/bin/python > taichi-aot-demo-configure-log.txt 2>&1
cmake --build build3 > taichi-aot-demo-build-log.txt 2>&1

taichi-aot-demo-configure-log.txt

taichi-aot-demo-build-log.txt

(base) zz@arcsoft-43% ./build3/headless/E1_hello_world_headless 
framework initialized
initialized!
stepped! (fps=1.88679e+07)
stepped! (fps=4.16899)
framework finalized
(base) zz@arcsoft-43% ./build3/headless/E2_mpm88_headless      
framework initialized
initialized!
stepped! (fps=3.57143e+07)
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E2_mpm88_headless
(base) zz@arcsoft-43% ./build3/headless/E3_implicit_fem_headless 
framework initialized
initialized!
stepped! (fps=3.22581e+07)
stepped! (fps=3.95419)
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E3_implicit_fem_headless
jim19930609 commented 1 year ago

I tried exactly the same compilation options and commands locally and was not able to reproduce.

The other thing you can try is goto taichi-aot-demo/mpm88_desktop and setup the linux_compile_and_run.sh - just set BACKEND_NAME to vulkan and TAICHI_REPO to the root dir of taichi. Then execute linux_compile_and_run.sh

BACKEND_NAME="vulkan" # cuda, x64, vulkan
TAICHI_REPO="/home/taichigraphics/workspace/taichi" # example: /home/taichigraphics/workspace/taichi

This example just used a different renderer and the algorithm stays the same

zchrissirhcz commented 1 year ago

I tried exactly the same compilation options and commands locally and was not able to reproduce.

The other thing you can try is goto taichi-aot-demo/mpm88_desktop and setup the linux_compile_and_run.sh - just set BACKEND_NAME to vulkan and TAICHI_REPO to the root dir of taichi. Then execute linux_compile_and_run.sh

BACKEND_NAME="vulkan" # cuda, x64, vulkan
TAICHI_REPO="/home/taichigraphics/workspace/taichi" # example: /home/taichigraphics/workspace/taichi

This example just used a different renderer and the algorithm stays the same

The mpm88_desktop run ok:

图片

jim19930609 commented 1 year ago

Great~ I think you can also play with the other ones like implicit_fem, sph, comet (LLVM only), taichi_sparse(LLVM only) - they all used the old renderer.

Meanwhile, I'm also concerned about the vulkan failure with the new renderer. Was wondering if you may help with printing out the Error Code upon failure? Just goto taichi-aot-demo/framework/src/taichi/aot_demo/renderer.cpp and insert:

inline void check_vulkan_result(VkResult result) {
  if (result < VK_SUCCESS) {
    std::cout << static_cast<int>(result) << std::endl;
    throw std::runtime_error("vulkan failed");
  }
}

2022-10-31 13-33-52 的屏幕截图

(I admit our error msg needs has way more to improve...)

Thanks!

zchrissirhcz commented 1 year ago

@jim19930609

OK, I added the result printing, rebuild and re-run, got:

(base) zz@arcsoft-43% ./build3/headless/E2_mpm88_headless 
framework initialized
initialized!
stepped! (fps=3.22581e+07)
-4
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E2_mpm88_headless

framework initialized
initialized!
stepped! (fps=2.43902e+07)
stepped! (fps=3.10749)
-4
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E3_implicit_fem_headless
(base) zz@arcsoft-43% 
zchrissirhcz commented 1 year ago
(base) zz@arcsoft-43% nvidia-smi
Mon Oct 31 14:05:27 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.76       Driver Version: 515.76       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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 ...  Off  | 00000000:01:00.0  On |                  N/A |
|  0%   52C    P8    23W / 245W |    690MiB /  8192MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1396      G   /usr/lib/xorg/Xorg                394MiB |
|    0   N/A  N/A      8246      G   /usr/bin/kwin_x11                  16MiB |
|    0   N/A  N/A      8250      G   /usr/bin/plasmashell               44MiB |
|    0   N/A  N/A      8310      G   ...nda.youdu/files/bin/youdu        9MiB |
|    0   N/A  N/A      8355      G   /usr/lib/firefox/firefox          150MiB |
|    0   N/A  N/A     71795      G   ...RendererForSitePerProcess       65MiB |
+-----------------------------------------------------------------------------+

vulkaninfo output: vkinfo.txt

jim19930609 commented 1 year ago

Many thanks! Let me investigate that

ailzhang commented 1 year ago

@zchrissirhcz would you mind also try turning on https://github.com/taichi-dev/taichi-aot-demo/blob/master/framework/src/taichi/aot_demo/entry_points/glfw.cpp#L13 as true and share the log of validation errors here? Thanks a ton!

zchrissirhcz commented 1 year ago

@zchrissirhcz would you mind also try turning on https://github.com/taichi-dev/taichi-aot-demo/blob/master/framework/src/taichi/aot_demo/entry_points/glfw.cpp#L13 as true and share the log of validation errors here? Thanks a ton!

Hi @ailzhang , I do modification as you suggested, rebuild & rerun, got:

(base) zz@arcsoft-43% ./build3/headless/E1_hello_world_headless 
framework initialized
initialized!
stepped! (fps=3.44828e+07)
stepped! (fps=4.19708)
framework finalized
(base) zz@arcsoft-43% ./build3/headless/E2_mpm88_headless      
framework initialized
initialized!
stepped! (fps=3.44828e+07)
-4
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E2_mpm88_headless
(base) zz@arcsoft-43% ./build3/headless/E3_implicit_fem_headless 
framework initialized
initialized!
stepped! (fps=2.94118e+07)
stepped! (fps=3.84559)
-4
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/headless/E3_implicit_fem_headless
ailzhang commented 1 year ago

oh @zchrissirhcz try running ./build3/glfw/E2_mpm88_glfw in this case? (which will give you a lot of validation errors IIUC

zchrissirhcz commented 1 year ago
(base) zz@arcsoft-43% ./build3/glfw/E2_mpm88_glfw
Vulkan Validation: loader_validate_layers: Layer 0 does not exist in the list of available layers
-6
terminate called after throwing an instance of 'std::runtime_error'
  what():  vulkan failed
zsh: abort (core dumped)  ./build3/glfw/E2_mpm88_glfw
ailzhang commented 1 year ago

@zchrissirhcz sorry for suggesting this, but https://www.reddit.com/r/vulkan/comments/p8krz8/vk_layer_khronos_validation_layer_not_present/ says rebooting the computer solved the problem for him/her :P

FYI in case this still doesn't work, we'll try to find a combo of RTX2080+ ubuntu20.04 +vulkan sdk 1.3 on our side to repro, but that may take longer so we'd like to bisect this down as far as possible. Thanks a lot!

zchrissirhcz commented 1 year ago

OK, rebooted my machine, and re-run. Still get same error message.