AmirMardan / PyFWI

This repository is for PyFWI, a Python package for seismic FWI and reservoir monitoring (time-lapse FWI)
https://pyfwi.readthedocs.io/en/latest/
GNU General Public License v3.0
59 stars 11 forks source link

Issue in the example code #11

Open khc800 opened 8 months ago

khc800 commented 8 months ago

Hi Amir, In the example code:

# Create the wave object
W = wave.WavePropagator(inpa, src, rec_loc, model_shape,
                        n_well_rec=n_well_rec,
                        components=seisout, chpr=0)

# Call the forward modelling 
d_obs = W.forward_modeling(model, show=False)  # show=True can show the propagation of the wave

When I run the code, I keep receiving this error:

Cell In[6], line 7
      2 W = wave.WavePropagator(inpa, src, rec_loc, model_shape,
      3                         n_well_rec=n_well_rec,
      4                         components=seisout, chpr=0)
      6 # Call the forward modelling 
----> 7 d_obs = W.forward_modeling(model, show=False)  # show=True can show the propagation of the wave

File ~/anaconda3/envs/env3/lib/python3.10/site-packages/PyFWI/wave_propagation.py:898, in WavePropagator.forward_modeling(self, model0, show)
    896 self.pml_preparation(model['vp'].max())
    897 self.elastic_buffers(model)
--> 898 seismo = self.forward_propagator(model)
    899 data = acq.seismic_section(seismo, self.components, shape=self.seismo_shape)
    900 return data

File ~/anaconda3/envs/env3/lib/python3.10/site-packages/PyFWI/wave_propagation.py:648, in WavePropagator.forward_propagator(self, model)
    642     self.prg.MakeAllZero(self.queue, (self.tnz, self.tnx), None,
    643                          self.vx_b, self.vz_b,
    644                          self.taux_b, self.tauz_b, self.tauxz_b
    645                          )
    646     # print(s)
    647     # print(coeff)
--> 648     self.__kernel(s, coeff)
    650 if self.acq_type == 2:
    651     for par in self.seismogram:

File ~/anaconda3/envs/env3/lib/python3.10/site-packages/PyFWI/wave_propagation.py:714, in WavePropagator.__kernel(self, s, coeff)
    712 for t in np.arange(self.nt):
    713     if t % self.dt_scale == 0:
--> 714         self.__injSrc(t_src, s)
    715         # t_src += 1.0
    716     print(t)

File ~/anaconda3/envs/env3/lib/python3.10/site-packages/PyFWI/wave_propagation.py:661, in WavePropagator.__injSrc(self, t, s)
    656 src_kv_x, src_kv_z, src_kt_x, src_kt_z, src_kt_xz = np.float32(self.src(t))
    657 # print(t.astype(np.float32).type)
    658 # print(t)
    659 # print(type(src_kt_xz))
    660 # t = np.float32(t)
--> 661 self.prg.injSrc(self.queue, (self.tnz, self.tnx), None,
    662                 self.vx_b, self.vz_b,
    663                     self.taux_b, self.tauz_b, self.tauxz_b,
    664                 self.seismogramid_vx_b, self.seismogramid_vz_b,
    665                 self.seismogramid_taux_b, self.seismogramid_tauz_b, self.seismogramid_tauxz_b,
    666                 self.dxr,
    667                 self.srcx[s], self.srcz[s],
    668                 src_kv_x, src_kv_z,
    669                 src_kt_x, src_kt_z, 
    670                 t
    671                 )

File ~/anaconda3/envs/env3/lib/python3.10/site-packages/pyopencl/__init__.py:901, in _add_functionality.<locals>.kernel_call(self, queue, global_size, local_size, *args, **kwargs)
    895 def kernel_call(self, queue, global_size, local_size, *args, **kwargs):
    896     # __call__ can't be overridden directly, so we need this
    897     # trampoline hack.
    898 
    899     # Note: This is only used for the generic __call__, before
    900     # kernel_set_scalar_arg_dtypes is called.
--> 901     return self._enqueue(self, queue, global_size, local_size, *args, **kwargs)

File <pyopencl invoker for 'injSrc'>:7, in enqueue_knl_injSrc(self, queue, global_size, local_size, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, global_offset, g_times_l, allow_empty_ndrange, wait_for)

LogicError: clSetKernelArg failed: INVALID_ARG_SIZE - when processing arg#18 (1-based): 
AmirMardan commented 8 months ago

Is it exactly this example file that you're using? https://github.com/AmirMardan/PyFWI/blob/main/example/gradient_example.ipynb

Could you please specify your system and the version of pyopencl that you use?

Also, before calling d_obs = W.forward_modeling(model, show=False), please print W.nt and let me know what value you get.

Hector9706 commented 7 months ago

Hello, I have exactly the same problem with the basic example in the documentation. I am running the code in Google Collab. Below is the requested data:

W.nt: 1400 OS: Linux-Ubuntu 22.04.3 LTS PyOpenCL: 2024.1

AmirMardan commented 7 months ago

Hello, I have exactly the same problem with the basic example in the documentation. I am running the code in Google Collab. Below is the requested data:

W.nt: 1400 OS: Linux-Ubuntu 22.04.3 LTS PyOpenCL: 2024.1

Please uninstall the package and install the new version from issue_11 repository. If it works, I will merge this branch to dev and finally main.

So, before loading PyFWI, run these two lines in a cell,

!pip uninstall -y PyFWI
!pip install git+https://github.com/AmirMardan/PyFWI.git@issue_11
Hector9706 commented 7 months ago

It worked for me thank!