taichi-dev / taichi

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

Installation Issue - taichi_python.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN6taichi2io10VirtualDir11from_fs_dirERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE #8350

Open HimangiM opened 1 year ago

HimangiM commented 1 year ago

Hi,

Thank you for sharing Taichi! I am new in this domain and I am currently trying to install taichi from source via this documentation (https://docs.taichi-lang.org/docs/dev_install). If I run "./build.py --shell" and "python3 setup.py develop", the compilation runs successfully. However, I am running into the following error if run "import taichi" command. Any suggestions of where I might be going wrong or how I can fix the error? Thanks!

If I run the command

import taichi

I run into the following issue

Share object taichi_python import failed, check this page for possible solutions:
https://docs.taichi-lang.org/docs/install
Traceback (most recent call last):
  File "python/taichi/examples/simulation/mpm128.py", line 1, in <module>
    import taichi as ti
  File "/home/hmittal/diff-sim/taichi/python/taichi/__init__.py", line 1, in <module>
    from taichi._funcs import *
  File "/home/hmittal/diff-sim/taichi/python/taichi/_funcs.py", line 3, in <module>
    from taichi.lang import impl, ops
  File "/home/hmittal/diff-sim/taichi/python/taichi/lang/__init__.py", line 1, in <module>
    from taichi.lang import impl, simt
  File "/home/hmittal/diff-sim/taichi/python/taichi/lang/impl.py", line 6, in <module>
    from taichi._lib import core as _ti_core
  File "/home/hmittal/diff-sim/taichi/python/taichi/_lib/__init__.py", line 1, in <module>
    from taichi._lib.utils import ti_python_core as core
  File "/home/hmittal/diff-sim/taichi/python/taichi/_lib/utils.py", line 110, in <module>
    ti_python_core = import_ti_python_core()
  File "/home/hmittal/diff-sim/taichi/python/taichi/_lib/utils.py", line 57, in import_ti_python_core
    raise e from None
  File "/home/hmittal/diff-sim/taichi/python/taichi/_lib/utils.py", line 46, in import_ti_python_core
    from taichi._lib.core import taichi_python as core  # pylint: disable=C0415
ImportError: /home/hmittal/diff-sim/taichi/python/taichi/_lib/core/taichi_python.cpython-38-x86_64-linux-gnu.so: undefined symbol: _ZN6taichi2io10VirtualDir11from_fs_dirERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

I am also sharing my system specifications:

**Ubuntu Version**
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

**Clang version:** 
clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

LLVM version: 15.0.5

Python version: Python 3.8.18

Any suggestions or help would be greatly appreciated. Thanks!

lin-hitonami commented 1 year ago

IIRC python build.py create an isolated Python environment by default, and you then install taichi in that environment. Are you testing in the created environment or in the native environment? If you want to install taichi in the native environment, you can specify --python=native in python build.py command, see this section for more information.

HimangiM commented 1 year ago

Thank you for the quick response! I tried the following set of commands with and without a conda environment, however, I am facing the same error (same error trace as above). I am sharing the list of commands:

With conda environment

conda create -n diffsim5 python=3.8.10
conda activate diffsim5
git clone --recursive https://github.com/taichi-dev/taichi
cd taichi
export TAICHI_CMAKE_ARGS="-DTI_WITH_VULKAN:BOOL=ON -DTI_WITH_CUDA:BOOL=ON"
./build.py --python=native
python3 setup.py develop

Without conda environment

git clone --recursive https://github.com/taichi-dev/taichi
cd taichi
export TAICHI_CMAKE_ARGS="-DTI_WITH_VULKAN:BOOL=ON -DTI_WITH_CUDA:BOOL=ON"
./build.py --shell
python3 setup.py develop

I would be highly grateful if there can be some help in resolving the issue. I am quite interested in running taichi and taichi_mpm (https://github.com/yuanming-hu/taichi_mpm) especially.

bobcao3 commented 1 year ago

taichi_mpm is an legacy repo, it wouldn't work now with current version of Taichi. If you are interested in something similar, you can use this: https://github.com/taichi-dev/taichi_elements . It also runs with the pip installed version of taichi

HimangiM commented 1 year ago

I see. Thank you for pointing to the taichi_elements! I am curious to know, would taichi_mpm not work with "pip install taichi" as well as installing taichi (legacy) from source (https://docs.taichi-lang.org/docs/dev_install#build-taichi-from-source)?

expenses commented 1 year ago

I've also been running into symbol errors when trying to compile taichi for AMDGPU support. I'm running the following:

set -x TAICHI_CMAKE_ARGS "-DTI_WITH_CUDA=OFF -DTI_WITH_AMDGPU=ON"
python ./build.py --shell --python native
python3 setup.py develop --user
ashley@archlinux ~ [1]> ti
Share object taichi_python import failed, check this page for possible solutions:
https://docs.taichi-lang.org/docs/install
Traceback (most recent call last):
  File "/home/ashley/.local/bin/ti", line 33, in <module>
    sys.exit(load_entry_point('taichi', 'console_scripts', 'ti')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ashley/.local/bin/ti", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/ashley/projects/taichi/python/taichi/__init__.py", line 1, in <module>
    from taichi._funcs import *
  File "/home/ashley/projects/taichi/python/taichi/_funcs.py", line 3, in <module>
    from taichi.lang import impl, ops
  File "/home/ashley/projects/taichi/python/taichi/lang/__init__.py", line 1, in <module>
    from taichi.lang import impl, simt
  File "/home/ashley/projects/taichi/python/taichi/lang/impl.py", line 6, in <module>
    from taichi._lib import core as _ti_core
  File "/home/ashley/projects/taichi/python/taichi/_lib/__init__.py", line 1, in <module>
    from taichi._lib.utils import ti_python_core as core
  File "/home/ashley/projects/taichi/python/taichi/_lib/utils.py", line 110, in <module>
    ti_python_core = import_ti_python_core()
                     ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ashley/projects/taichi/python/taichi/_lib/utils.py", line 57, in import_ti_python_core
    raise e from None
  File "/home/ashley/projects/taichi/python/taichi/_lib/utils.py", line 46, in import_ti_python_core
    from taichi._lib.core import taichi_python as core  # pylint: disable=C0415
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: /home/ashley/projects/taichi/python/taichi/_lib/core/taichi_python.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZNSt13runtime_errorD2Ev

OS: Arch Linux x86_64 6.5.5 python -V: Python 3.11.5 shell: fish 3.6.1

Note that I did have to patch a few small things to make compliation work on Arch: https://github.com/taichi-dev/taichi/compare/6b563a2a7c20eff40cbbeba00a63e6b03a7c81b9...expenses:taichi:0cddfc51573e4258015ecf8081a37316b6e8398b. Mostly making sure all pip packages are installed manually and that it allows compilation with cmake 16.

galeselee commented 1 year ago

I've also been running into symbol errors when trying to compile taichi for AMDGPU support. I'm running the following:

set -x TAICHI_CMAKE_ARGS "-DTI_WITH_CUDA=OFF -DTI_WITH_AMDGPU=ON"
python ./build.py --shell --python native
python3 setup.py develop --user

Could you try again following the process mentioned in this issue?

expenses commented 1 year ago

@GaleSeLee yep, I found that disabling more backends that I wasn't using helped. Thanks!