taichi-dev / meshtaichi

MeshTaichi: A Compiler for Efficient Mesh-based Operations (SIGGRAPH Asia 2022)
214 stars 11 forks source link

[error]CUDA_ERROR_ILLEGAL_ADDRESS when running the mpm_lag example #8

Closed chunleili closed 1 year ago

chunleili commented 1 year ago

Hi, When I run the mpm_lag case, I come across the CUDA_ERROR_ILLEGAL_ADDRESS.

The only modification is in the run.py, where I drop the initial transform of the model.

image

But if I recover the transform, everything is OK.

Here is my source file which can reproduce the BUG:

meshtaichi.zip

Initially(before doing the MPM computation), the program is OK. And I can see the imported mesh. But it crashes after I press SPACE(run simulation).

My totoal GPU memory is 6GB, and I allocate 4GB initially.

taichi Version:1.4.1 platform: win-10

error log

c:\Users\GRBJ200045\Desktop\meshtaichi\lag_mpm\mpm.py:82: DeprecationWarning: Calling builtin function "max" in Taichi scope is deprecated. Please use "ti.max" instead.
  v_max = max(v_max, abs(v[i]))       
[E 02/13/23 14:54:41.104 23328] [taichi/rhi/cuda/cuda_driver.h:taichi::lang::CUDADriverFunction<void * *,char const *,unsigned int,unsigned int *,void * *>::operator ()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling module_load_data_ex (cuModuleLoadDataEx)

Traceback (most recent call last):    
  File "c:\Users\GRBJ200045\Desktop\meshtaichi\lag_mpm\run.py", line 92, in 
<module>
    solve(1, fems)
  File "c:\Users\GRBJ200045\Desktop\meshtaichi\lag_mpm\mpm.py", line 127, in solve
    fems[i].f.fill(0.0)
  File "C:\Users\GRBJ200045\AppData\Roaming\Python\Python310\site-packages\taichi\lang\matrix.py", line 1272, in fill
    field_fill_python_scope(self, val)  File "C:\Users\GRBJ200045\AppData\Roaming\Python\Python310\site-packages\taichi\lang\kernel_impl.py", line 974, 
in wrapped
    return primal(*args, **kwargs)    
  File "C:\Users\GRBJ200045\AppData\Roaming\Python\Python310\site-packages\taichi\lang\kernel_impl.py", line 901, 
in __call__
    return self.runtime.compiled_functions[key](*args)
  File "C:\Users\GRBJ200045\AppData\Roaming\Python\Python310\site-packages\taichi\lang\kernel_impl.py", line 826, 
in func__
    raise e from None
  File "C:\Users\GRBJ200045\AppData\Roaming\Python\Python310\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 * *,char const *,unsigned int,unsigned int 
*,void * *>::operator ()@88] CUDA Error CUDA_ERROR_ILLEGAL_ADDRESS: an illegal memory access was encountered while calling module_load_data_ex (cuModuleLoadDataEx)
GLFW Error 65537: The GLFW library is not initialized
[E 02/13/23 14:54:41.214 23328] [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)
g1n0st commented 1 year ago

This is because the simulation of this demo uses MPM, and the range of the grid inside is [0.0, 1.0]^3. If the initial model size is not within this range, the particles will be outside the range of the grid during particle-to-grid, resulting in illegal memory access.