运行程序出错

错误信息显示我用的max()函数有问题,但是很奇怪,就是前几帧都是好的,不知道那一帧突然就报错了。

错误信息如下:

[Taichi] version 1.4.1, llvm 15.0.1, commit e67c674e, win, python 3.7.8
[Taichi] Starting on arch=cuda
Traceback (most recent call last):
[E 03/08/23 21:54:58.481 10860] [taichi/rhi/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *,void *,unsigned __int64>::operator ()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling memcpy_host_to_device (cuMemcpyHtoD_v2)
File “C:/Users/yanzh/Documents/GitHub/ttttest.py”, line 467, in

max_T = max(temperature.to_numpy())

File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\util.py”, line 310, in wrapped
return func(*args, **kwargs)
File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\field.py”, line 302, in to_numpy
tensor_to_ext_arr(self, arr)
File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\kernel_impl.py”, line 974, in wrapped
return primal(*args, **kwargs)
File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\kernel_impl.py”, line 901, in call
return self.runtime.compiled_functionskey
File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\kernel_impl.py”, line 826, in func__
raise e from None
File “C:\Users\yanzh\AppData\Local\Programs\Python\Python37\lib\site-packages\taichi\lang\kernel_impl.py”, line 823, in func__
t_kernel(launch_ctx)
RuntimeError: [taichi/rhi/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *,void *,unsigned __int64>::operator ()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling memcpy_host_to_device (cuMemcpyHtoD_v2)
[E 03/08/23 21:54:58.595 10860] [taichi/rhi/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void *>::operator ()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling stream_synchronize (cuStreamSynchronize)

进程已结束,退出代码 -1073740791 (0xC0000409)

max_T = max(temperature.to_numpy()是在python scope跑的么?

对的,前几帧是好的。
我检查了一下,好像是用旧版本就OK,不过旧版本运行到这里我的仿真直接炸了。可能存在个别数据NAN了。

这段代码涉及 device to host的memcpy, 但是错误里显示的却是host to device memcpy的错误。你要不在进行 host device之间memcpy的时候加一下ti.sync()

或者是否可以贴一个最小复现代码?

发邮箱了,有进展了踢我一脚 :grinning:

我看了下代码,有点长,能帮忙提交一个小一点复现代码嘛?

hello~ 代码的部分可以贴在帖子里吗,论坛是社区互助的平台,公开的信息可以造福一下遇到同样问题的同学~

你好,我也遇到了这个问题,请问你那边解决了吗? 怎么解决的呢