Skip to main content

Frequently Asked Questions

Why does my pip complain package not found when installing Taichi?#

You may have a Python interpreter with an unsupported version. Currently, Taichi only supports Python 3.6/3.7/3.8 (64-bit) . For more information about installation related issues, please check Installation Troubleshooting.

Does Taichi provide built-in constants such as ti.pi?#

There is no built-in constant such as pi. We recommended using math.pi directly.

Outer-most loops in Taichi kernels are by default parallel. How can I serialize one of them?#

A solution is to add an additional ghost loop with only one iteration outside the loop you want to serialize.

for _ in range(1):  # This "ghost" loop will be "parallelized", but with only one thread. Therefore, the containing loop below is serialized.    for i in range(100):  # The loop you want to serialize        ...

What is the most convenient way to load images into Taichi fields?#

One feasible solution is field.from_numpy(ti.imread('filename.png')).

Can Taichi interact with other Python packages such as matplotlib?#

Yes, Taichi supports various popular Python packages. Please check out Interacting with other Python packages.

How do I declare a field with a dynamic length?#

The dynamic SNode supports variable-length fields. It acts similarly to std::vector in C++ or list in Python.


An alternative solution is to allocate a large enough dense field, with a corresponding 0-D field field_len[None] tracking its length. In practice, programs allocating memory using dynamic SNodes may be less efficient than using dense SNodes, due to dynamic data structure maintainance overheads.

How do I program on less structured data structures (such as graphs and tetrahedral meshes) in Taichi?#

These structures have to be decomposed into 1D Taichi fields. For example, when representing a graph, you can allocate two fields, one for the vertices and the other for the edges. You can then traverse the elements using for v in vertices or for v in range(n).