devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation
http://www.devitoproject.org
MIT License
558 stars 226 forks source link

Error when trying to run 03_fwi.ipynb with GPU #2086

Open yymss opened 1 year ago

yymss commented 1 year ago

Dear Devito team,

I am trying to run the tutorial notebook /devito/examples/seismic/tutorials/03_fwi.ipynb on my machine. It runs normally when using the CPU, but I would like to use the GPU. I tried setting %env DEVITO_PLATFORM=nvidiaX, but I encountered an error.

/tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c: In function ‘initdamp’: /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] 152 | return 0; | ^ /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] /tmp/devito-jitcache-uid1009/d3a3d2e6153c3468b5bd394c5b3e8c0ed9ec93cb.c:152:10: warning: ‘’ is used uninitialized in this function [-Wuninitialized] Output exceeds the size limit. Open the full output data in a text editor

CompileError Traceback (most recent call last) Cell In[3], line 9 6 spacing = (10., 10.) # Grid spacing in m. The domain size is now 1km by 1km 7 origin = (0., 0.) # Need origin to define relative source and receiver locations ----> 9 model = demo_model('circle-isotropic', vp_circle=3.0, vp_background=2.5, 10 origin=origin, shape=shape, spacing=spacing, nbl=40) 12 model0 = demo_model('circle-isotropic', vp_circle=2.5, vp_background=2.5, 13 origin=origin, shape=shape, spacing=spacing, nbl=40, 14 grid = model.grid) 16 plot_velocity(model)

File ~/anaconda3/envs/demo/lib/python3.9/site-packages/examples/seismic/preset_models.py:247, in demo_model(preset, *kwargs) 244 y, x = np.ogrid[-a:shape[0]-a, -b:shape[1]-b] 245 v[xx + yy <= rr] = vp --> 247 return SeismicModel(space_order=space_order, vp=v, origin=origin, shape=shape, 248 dtype=dtype, spacing=spacing, nbl=nbl, bcs="damp", 249 fs=fs, **kwargs) 251 elif preset.lower() in ['marmousi-isotropic', 'marmousi2d-isotropic']: 252 shape = (1601, 401)

File ~/anaconda3/envs/demo/lib/python3.9/site-packages/examples/seismic/model.py:273, in SeismicModel.init(self, origin, spacing, shape, space_order, vp, nbl, fs, dtype, subdomains, bcs, grid, kwargs) 271 def init(self, origin, spacing, shape, space_order, vp, nbl=20, fs=False, 272 dtype=np.float32, subdomains=(), bcs="mask", grid=None, kwargs): --> 273 super(SeismicModel, self).init(origin, spacing, shape, space_order, nbl, ... 208 print("FAILED compiler invocation:" + " ".join(cc_cmdline), 209 file=sys.stderr) --> 210 raise CompileError("module compilation failed")

CompileError: module compilation failed

I have read some issues and set %env DEVITO_ARCH=gcc but still filled. Thank you for your help.

Best regards, yym

mloubout commented 1 year ago

To run on nvidia gpus with DEVITO_PLATFORM=nvidiaX you need to set the arch and language to valid ones, namely DEVITO_LANGUAGE=openmp with DEVITO_ARCH=nvc or DEVITO_LANGUAGE=openacc with DEVITO_ARCH=nvc

You can also use clang instead of nvc if you built llvm yourself to support openmp/openacc offloading

yymss commented 1 year ago

Thank you for your help! I’m new to NVIDIA and Devito. I have added %env DEVITO_PLATFORM=nvidiaX %env DEVITO_LANGUAGE=openacc %env DEVITO_ARCH = nvc and got the nvc++ compiler isn't available on this system Do I need to install the NVIDIA HPC SDK to use GPU on DeVito?

mloubout commented 1 year ago

Yes you will need either the SDK or another way to get the Nvidia compiler suite

georgebisbas commented 4 months ago

Maybe this can be closed? Any updates?