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

[Lang] print fails on a simple test case with windows' ipython & jupyter notebook #1163

Open
mrbulb opened this issue Jun 6, 2020 · 2 comments
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@mrbulb
Copy link

mrbulb commented Jun 6, 2020

Describe the bug
When I run the print code with ipython in Win10 platform and jupyter notebook in Win10/Ubuntu platform, it fails to print the ouput

Log/Screenshots
IPython in Win10 platform
NOTE:it will print all output until the quit
bug1

Jupyter notebook
bug2

To Reproduce

import taichi as ti

# initialization
ti.init(arch=ti.gpu)

@ti.kernel
def hello(i: ti.i32):
    a = 40
    print('Hello world!', a + i)
    
hello(2)

If you have local commits (e.g. compile fixes before you reproduce the bug), please make sure you first make a PR to fix the build errors and then report the bug.

@mrbulb mrbulb added the potential bug Something that looks like a bug but not yet confirmed label Jun 6, 2020
@mrbulb mrbulb changed the title [Lang] print fails on a simple test case with windows' ipython & jupyter [Lang] print fails on a simple test case with windows' ipython & jupyter notebook Jun 6, 2020
@archibate
Copy link
Collaborator

GPU kernels won't really be executed until ti.sync() or host access, for performance reasons.
So if you:

import taichi as ti

# initialization
ti.init(arch=ti.gpu)

@ti.kernel
def hello(i: ti.i32):
    a = 40
    print('Hello world!', a + i)

hello(2)
ti.sync()

It will print things in time.

Or ti.init(arch=ti.cpu) solves the issue too, since CPU kernels don't have this mechanism.

Sorry about not mentioning this in documentation, I'll doc this behavior about ti.sync() later.

@mrbulb
Copy link
Author

mrbulb commented Jun 6, 2020

GPU kernels won't really be executed until ti.sync() or host access, for performance reasons.
So if you:

import taichi as ti

# initialization
ti.init(arch=ti.gpu)

@ti.kernel
def hello(i: ti.i32):
    a = 40
    print('Hello world!', a + i)

hello(2)
ti.sync()

It will print things in time.

Or ti.init(arch=ti.cpu) solves the issue too, since CPU kernels don't have this mechanism.

Sorry about not mentioning this in documentation, I'll doc this behavior about ti.sync() later.

thank you for your quick reply, ti.init(arch=ti.cpu) or ti.sync() is now work for me when using IPython in windows platform
However it still doesn't work for jupyter notebok, may be it is the same problem like @liaopeiyuan mentions in #1136 (comment)

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

3 participants