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

ti.random() Fails #2023

Closed
squarefk opened this issue Nov 3, 2020 · 2 comments · Fixed by #2042
Closed

ti.random() Fails #2023

squarefk opened this issue Nov 3, 2020 · 2 comments · Fixed by #2042
Labels
potential bug Something that looks like a bug but not yet confirmed welcome contribution

Comments

@squarefk
Copy link
Contributor

squarefk commented Nov 3, 2020

import taichi as ti

ti.init(arch=ti.gpu, default_fp=ti.f64)

x = ti.field(dtype=ti.f64)
ti.root.dense(ti.i, 10).place(x)

@ti.kernel
def failure():
    x[0] = ti.random(dtype=ti.f64)
    print(x[0])

if __name__ == "__main__":
    failure()
[Taichi] mode=development
[Taichi] preparing sandbox at /tmp/taichi-rioea07h
[Taichi] <dev mode>, llvm 10.0.0, commit 1ea0ec85, linux, python 3.6.9
[Taichi] Starting on arch=cuda
[Taichi] materializing...
python3: /home/squarefk/repos/llvm-10.0.0.src/lib/IR/Instructions.cpp:1358: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
[E 11/03/20 15:12:26.095] Received signal 6 (Aborted)


***********************************
* Taichi Compiler Stack Traceback *
***********************************
/tmp/taichi-rioea07h/taichi_core.so: taichi::Logger::error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
/tmp/taichi-rioea07h/taichi_core.so: taichi::signal_handler(int)
/lib/x86_64-linux-gnu/libc.so.6(+0x3efd0) [0x7f3910910fd0]
/lib/x86_64-linux-gnu/libc.so.6: gsignal
/lib/x86_64-linux-gnu/libc.so.6: abort
/lib/x86_64-linux-gnu/libc.so.6(+0x3042a) [0x7f391090242a]
/lib/x86_64-linux-gnu/libc.so.6(+0x304a2) [0x7f39109024a2]
/tmp/taichi-rioea07h/taichi_core.so(+0x804dd0) [0x7f390aaefdd0]
/tmp/taichi-rioea07h/taichi_core.so(+0x804fb3) [0x7f390aaeffb3]
/tmp/taichi-rioea07h/taichi_core.so(+0x3e189c) [0x7f390a6cc89c]
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenLLVM::visit(taichi::lang::GlobalStoreStmt*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::GlobalStoreStmt::accept(taichi::lang::IRVisitor*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenLLVM::visit(taichi::lang::Block*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenLLVMCUDA::visit(taichi::lang::OffloadedStmt*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::OffloadedStmt::accept(taichi::lang::IRVisitor*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenLLVM::visit(taichi::lang::Block*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenLLVM::gen()
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::CodeGenCUDA::codegen()
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::KernelCodeGen::compile()
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::Program::compile_to_backend_executable(taichi::lang::Kernel&, taichi::lang::OffloadedStmt*)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::Program::compile(taichi::lang::Kernel&)
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::Kernel::compile()
/tmp/taichi-rioea07h/taichi_core.so: taichi::lang::Kernel::operator()(taichi::lang::Kernel::LaunchContextBuilder&)
/tmp/taichi-rioea07h/taichi_core.so(+0x4d6e36) [0x7f390a7c1e36]
/tmp/taichi-rioea07h/taichi_core.so(+0x414211) [0x7f390a6ff211]
python3(_PyCFunction_FastCallDict+0x35c) [0x566bbc]
python3() [0x594a71]
python3() [0x54a971]
python3(_PyObject_FastCallKeywords+0x19c) [0x5a9dac]
python3() [0x50a433]
python3(_PyEval_EvalFrameDefault+0x444) [0x50beb4]
python3() [0x507be4]
python3() [0x588c8b]
python3(PyObject_Call+0x3e) [0x59fd0e]
python3(_PyEval_EvalFrameDefault+0x17e6) [0x50d256]
python3() [0x507be4]
python3(_PyFunction_FastCallDict+0x2e2) [0x508ec2]
python3() [0x594a01]
python3() [0x54a971]
python3(PyObject_Call+0x3e) [0x59fd0e]
python3(_PyEval_EvalFrameDefault+0x17e6) [0x50d256]
python3() [0x507be4]
python3() [0x509900]
python3() [0x50a2fd]
python3(_PyEval_EvalFrameDefault+0x444) [0x50beb4]
python3() [0x507be4]
python3(PyEval_EvalCode+0x23) [0x50ad03]
python3() [0x634e72]
python3(PyRun_FileExFlags+0x97) [0x634f27]
python3(PyRun_SimpleFileExFlags+0x17f) [0x6386df]
python3(Py_Main+0x591) [0x639281]
python3(main+0xe0) [0x4b0dc0]
/lib/x86_64-linux-gnu/libc.so.6: __libc_start_main
python3(_start+0x2a) [0x5b259a]

Internal error occurred. Check out this page for possible solutions:
https://taichi.readthedocs.io/en/stable/install.html#troubleshooting

@squarefk squarefk added the potential bug Something that looks like a bug but not yet confirmed label Nov 3, 2020
@squarefk
Copy link
Contributor Author

A temporary workaround is to use

x[0] = ti.cast(ti.random(dtype=ti.f32), ti.f64)

to replace

x[0] = ti.random(dtype=ti.f64)

@yuanming-hu
Copy link
Member

A lot of thanks to @victoriacity for pointing out the cause of the issue. I believe this has been fixed in #2042.

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 welcome contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants