Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

之前Taichi运行正常,突然就没法运行了。显示错误: ti.init(arch=ti.gpu) AttributeError: module 'taichi' has no attribute 'init' #2072

Closed
ben100118 opened this issue Nov 30, 2020 · 15 comments
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@ben100118
Copy link

import taichi as ti

ti.init(arch=ti.gpu)

n=320
pixels=ti.var(dt=ti.f32,shape=(n*2,n))

@ti.func
def complex_sqr(z):
return ti.Vector([z[0]**2-z[1]**2,z[1]*z[0]*2])

@ti.kernel
def paint(t:ti.f32):
for i,j in pixels:
c=ti.Vector([-0.8,ti.cos(t)*0.2])
z=ti.Vector([i/n-1,j/n-0.5])2
iterations=0
while z.norm() <20 and iterations < 50:
z=complex_sqr(z)+c
iterations+=1
pixels[i,j]=1-iterations
0.02

gui=ti.GUI("Julia Set",res=(n*2,n))

for i in range(1000000):
paint(i*0.03)
gui.set_image(pixels)
gui.show()

@ben100118 ben100118 added the potential bug Something that looks like a bug but not yet confirmed label Nov 30, 2020
@archibate
Copy link
Collaborator

你的文件名是不是taichi.py?

@ben100118
Copy link
Author

不是,我的文件名是2.py

@archibate
Copy link
Collaborator

archibate commented Dec 1, 2020 via email

@ben100118
Copy link
Author

输出结果:['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec']
Traceback (most recent call last):
File "E:/python program/taichi/try.py", line 3, in
print(ti.file,ti.version)
AttributeError: module 'taichi' has no attribute 'file'

我的taichi版本为0.7.9

@archibate
Copy link
Collaborator

archibate commented Dec 1, 2020 via email

@archibate
Copy link
Collaborator

print(ti.__path__)呢?

@ben100118
Copy link
Author

['E:\python program\taichi']

@archibate
Copy link
Collaborator

archibate commented Dec 1, 2020 via email

@ben100118
Copy link
Author

问题解决了,我把文件夹换了个名称就能运行了,谢谢!

@ben100118
Copy link
Author

ben100118 commented Dec 1, 2020 via email

@k-ye k-ye closed this as completed Dec 15, 2020
@asurada404
Copy link

asurada404 commented Aug 5, 2021

I have the same problems, and I have checked the filename and path

Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import taichi as ti
>>> ti.__path__
_NamespacePath(['/home/username/.local/lib/python3.6/site-packages/taichi'])
>>> ti.init(ti.cpu)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'taichi' has no attribute 'init'
>>> ti.__version__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'taichi' has no attribute '__version__'
>>> dir(ti)
['__doc__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
>>> ti.__name__
'taichi'

@archibate
Copy link
Collaborator

archibate commented Aug 6, 2021 via email

@asurada404
Copy link

Yes, the folder is not empty, the content is as follow:

username@username-ThinkPad-X1-Carbon-Gen-8:~/.local/lib/python3.6/site-packages/taichi$ pwd
/home/username/.local/lib/python3.6/site-packages/taichi
username@username-ThinkPad-X1-Carbon-Gen-8:~/.local/lib/python3.6/site-packages/taichi$ tree -L 3
.
├── assets
│   └── Go-Regular.ttf
├── examples
│   ├── algorithm
│   │   ├── invert_image_color.py
│   │   ├── laplace.py
│   │   ├── marching_squares.py
│   │   ├── mciso_advanced.py
│   │   ├── mgpcg_advanced.py
│   │   ├── mgpcg.py
│   │   ├── print_offset.py
│   │   ├── __pycache__
│   │   └── quadtree.py
│   ├── autodiff
│   │   ├── minimization.py
│   │   ├── mnist_download_data.py
│   │   ├── mnist.py
│   │   ├── __pycache__
│   │   ├── regression.py
│   │   └── simple_derivative.py
│   ├── features
│   │   ├── gui
│   │   ├── io
│   │   └── sparse
│   ├── minimal.py
│   ├── __pycache__
│   │   └── minimal.cpython-36.pyc
│   ├── rendering
│   │   ├── cornell_box.py
│   │   ├── particle_renderer.py
│   │   ├── __pycache__
│   │   ├── rasterizer.py
│   │   ├── renderer_utils.py
│   │   ├── sdf2d.py
│   │   ├── sdf_renderer.py
│   │   ├── simple_uv.py
│   │   └── taichi_logo.py
│   └── simulation
│       ├── ad_gravity.py
│       ├── cg_possion.py
│       ├── comet.py
│       ├── euler.py
│       ├── fem128.py
│       ├── fem99.py
│       ├── fractal.py
│       ├── game_of_life.py
│       ├── mass_spring_3d.py
│       ├── mass_spring_game.py
│       ├── math_utils.py
│       ├── mpm128.py
│       ├── mpm3d.py
│       ├── mpm88.py
│       ├── mpm99.py
│       ├── mpm_lagrangian_forces.py
│       ├── nbody_oscillator.py
│       ├── odop_solar.py
│       ├── pbf2d.py
│       ├── physarum.py
│       ├── __pycache__
│       ├── stable_fluid.py
│       ├── tree_gravity.py
│       ├── vortex_rings.py
│       └── waterwave.py
└── lib
    ├── runtime_cuda.bc
    ├── runtime_x64.bc
    ├── slim_libdevice.10.bc
    └── taichi_core.so

16 directories, 52 files


@k-ye
Copy link
Member

k-ye commented Aug 6, 2021

Sorry, please keep using 0.7.26 for now until #2642 gets resolved. Thanks!

@asurada404
Copy link

Thanks for the reply, 0.7.26 works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
None yet
Development

No branches or pull requests

4 participants