DeepGPR 0.0.8__tar.gz → 0.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. deepgpr-0.0.8/README.md → deepgpr-0.0.9/PKG-INFO +21 -34
  2. deepgpr-0.0.9/README.md +217 -0
  3. deepgpr-0.0.9/pyproject.toml +48 -0
  4. deepgpr-0.0.9/setup.cfg +4 -0
  5. deepgpr-0.0.9/src/DeepGPR/__init__.py +140 -0
  6. {deepgpr-0.0.8 → deepgpr-0.0.9}/src/DeepGPR/lib/deepgpr.cu +6 -9
  7. deepgpr-0.0.9/src/DeepGPR/lib/deepgpr.so +0 -0
  8. {deepgpr-0.0.8 → deepgpr-0.0.9/src/DeepGPR.egg-info}/PKG-INFO +11 -38
  9. deepgpr-0.0.9/src/DeepGPR.egg-info/SOURCES.txt +14 -0
  10. deepgpr-0.0.9/src/DeepGPR.egg-info/requires.txt +4 -0
  11. deepgpr-0.0.9/src/DeepGPR.egg-info/top_level.txt +1 -0
  12. deepgpr-0.0.8/.gitignore +0 -7
  13. deepgpr-0.0.8/CMakeLists.txt +0 -70
  14. deepgpr-0.0.8/Fig/2dfwiinit.png +0 -0
  15. deepgpr-0.0.8/Fig/2dfwipred.png +0 -0
  16. deepgpr-0.0.8/Fig/2dfwitrue.png +0 -0
  17. deepgpr-0.0.8/Fig/3dfwiinit.png +0 -0
  18. deepgpr-0.0.8/Fig/3dfwipred.png +0 -0
  19. deepgpr-0.0.8/Fig/3dfwitrue.png +0 -0
  20. deepgpr-0.0.8/Fig/example.png +0 -0
  21. deepgpr-0.0.8/examples/1.Forward.ipynb +0 -95
  22. deepgpr-0.0.8/examples/2.2DFWI.ipynb +0 -579
  23. deepgpr-0.0.8/examples/2DFWImodel.npy +0 -0
  24. deepgpr-0.0.8/examples/3.3DFWI.ipynb +0 -842
  25. deepgpr-0.0.8/examples/OverThrust.npy +0 -0
  26. deepgpr-0.0.8/license +0 -21
  27. deepgpr-0.0.8/pyproject.toml +0 -52
  28. deepgpr-0.0.8/src/DeepGPR/DeepGPR.egg-info/PKG-INFO +0 -85
  29. deepgpr-0.0.8/src/DeepGPR/DeepGPR.egg-info/SOURCES.txt +0 -6
  30. deepgpr-0.0.8/src/DeepGPR/DeepGPR.egg-info/top_level.txt +0 -1
  31. deepgpr-0.0.8/src/DeepGPR/__init__.py +0 -199
  32. deepgpr-0.0.8/src/DeepGPR/__pycache__/__init__.cpython-310.pyc +0 -0
  33. deepgpr-0.0.8/src/DeepGPR/__pycache__/common.cpython-310.pyc +0 -0
  34. deepgpr-0.0.8/src/DeepGPR/__pycache__/compute2.cpython-310.pyc +0 -0
  35. deepgpr-0.0.8/src/DeepGPR/__pycache__/multiscale.cpython-310.pyc +0 -0
  36. deepgpr-0.0.8/src/DeepGPR/__pycache__/visual.cpython-310.pyc +0 -0
  37. deepgpr-0.0.8/src/DeepGPR/requirements.txt +0 -1
  38. {deepgpr-0.0.8 → deepgpr-0.0.9}/src/DeepGPR/common.py +0 -0
  39. {deepgpr-0.0.8 → deepgpr-0.0.9}/src/DeepGPR/compute2.py +0 -0
  40. {deepgpr-0.0.8 → deepgpr-0.0.9}/src/DeepGPR/multiscale.py +0 -0
  41. {deepgpr-0.0.8 → deepgpr-0.0.9}/src/DeepGPR/wavelet.py +0 -0
  42. {deepgpr-0.0.8/src/DeepGPR → deepgpr-0.0.9/src}/DeepGPR.egg-info/dependency_links.txt +0 -0
@@ -1,3 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: DeepGPR
3
+ Version: 0.0.9
4
+ Summary: PyTorch and CUDA for GPR FWI
5
+ Author-email: Lei Liu <liulei990222@gmail.com>
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Topic :: Scientific/Engineering
10
+ Classifier: Topic :: Scientific/Engineering :: Physics
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: numpy
14
+ Requires-Dist: scipy
15
+ Requires-Dist: matplotlib
16
+ Requires-Dist: torch
17
+
1
18
  # DeepGPR
2
19
 
3
20
  DeepGPR provides a wave propagation module for PyTorch, designed for applications such as Ground Penetrating Radar (GPR) imaging and inversion. Its core concepts are derived from Deepwave. You can use it to perform both forward modeling and backpropagation—thereby enabling the simulation of wave propagation to generate synthetic data—as well as for Full Waveform Inversion (FWI). Furthermore, you can integrate this wave propagation functionality into a larger operational pipeline—incorporating various wavelets, loss functions, and other components—to achieve end-to-end forward and reverse propagation, powered by automatic differentiation and our high-performance operators.
@@ -19,40 +36,10 @@ Supports techniques such as checkpointing, DDP, and the utilization of CPU memor
19
36
  ## System Requirements
20
37
 
21
38
  - **OS**: Linux and Windows
22
- - **Python**: Python 3.8+
23
- - **GPU**: NVIDIA GPU with sufficient VRAM for 2D/3D computational grids
24
- - **CUDA**: NVIDIA driver and CUDA Toolkit
25
- - **Libraries**:
26
- - `torch` with CUDA support
27
- - `numpy`
28
- - `scipy`
29
- - `matplotlib`
30
-
31
- ### Additional Requirements for Building from Source
32
-
33
- DeepGPR contains a CUDA backend that is compiled during installation. Therefore, users who install the package from source need a working CUDA/C++ build environment.
34
-
35
- #### Linux
36
-
37
- - CUDA Toolkit with `nvcc`
38
- - GCC/G++ compiler compatible with the installed CUDA version
39
- - CMake 3.23 or later
39
+ - **Environment**: Python 3.8+, CUDA Toolkit
40
+ - **Libraries**: `torch` (with CUDA support), `numpy`, `scipy`, `matplotlib`
41
+ - **Hardware**: NVIDIA GPU with sufficient VRAM for 3D computational grids.
40
42
 
41
- #### Windows
42
-
43
- - CUDA Toolkit with `nvcc`
44
- - CMake 3.23 or later
45
- - Microsoft Visual Studio Build Tools or Visual Studio Community
46
- - The **Desktop development with C++** workload
47
- - MSVC C++ compiler `cl.exe`
48
- - Windows SDK
49
- - Optional: `ninja`
50
-
51
- On Windows, `nvcc` relies on the MSVC compiler to build CUDA code. Please make sure that both `nvcc` and `cl.exe` are available before running:
52
-
53
- ```bash
54
- pip install .
55
- ```
56
43
 
57
44
  ## Start
58
45
 
@@ -244,4 +231,4 @@ If you find our codes useful, please kindly cite this article. Thanks.
244
231
 
245
232
  publisher={Elsevier}
246
233
 
247
- }
234
+ }
@@ -0,0 +1,217 @@
1
+ # DeepGPR
2
+
3
+ DeepGPR provides a wave propagation module for PyTorch, designed for applications such as Ground Penetrating Radar (GPR) imaging and inversion. Its core concepts are derived from Deepwave. You can use it to perform both forward modeling and backpropagation—thereby enabling the simulation of wave propagation to generate synthetic data—as well as for Full Waveform Inversion (FWI). Furthermore, you can integrate this wave propagation functionality into a larger operational pipeline—incorporating various wavelets, loss functions, and other components—to achieve end-to-end forward and reverse propagation, powered by automatic differentiation and our high-performance operators.
4
+
5
+
6
+ ## Features
7
+
8
+ Supports 2D and 3D forward modeling of Maxwell's equations—via the Finite-Difference Time-Domain (FDTD) method—for both single and multiple excitation scenarios.
9
+
10
+ Gradients of the output receiver data can be computed with respect to model parameters (relative permittivity, conductivity), the initial wavefield, and source amplitudes.
11
+
12
+ Utilizes CPML, allowing the width of the PML layer to be configured independently for each boundary.
13
+
14
+ All operations are executed on the GPU.
15
+
16
+ Supports techniques such as checkpointing, DDP, and the utilization of CPU memory to minimize GPU memory consumption, thereby enabling the execution of large-scale models.
17
+
18
+
19
+ ## System Requirements
20
+
21
+ - **OS**: Linux and Windows
22
+ - **Environment**: Python 3.8+, CUDA Toolkit
23
+ - **Libraries**: `torch` (with CUDA support), `numpy`, `scipy`, `matplotlib`
24
+ - **Hardware**: NVIDIA GPU with sufficient VRAM for 3D computational grids.
25
+
26
+
27
+ ## Start
28
+
29
+ Before use, you must ensure that you have an NVIDIA graphics card and have installed a CUDA-enabled version of PyTorch.
30
+
31
+ DeepGPR can then be installed using
32
+
33
+ ```bash
34
+ pip install DeepGPR
35
+ ```
36
+
37
+
38
+
39
+ ## A Small Forward Modeling Test
40
+
41
+ ```python
42
+ import torch
43
+ import DeepGPR
44
+ import matplotlib.pyplot as plt
45
+
46
+ # Set up the parameters and models
47
+ device=torch.device("cuda")
48
+ dx=0.02
49
+ dt=3e-11
50
+ nt=2000
51
+ er = torch.ones(100, 100,1) * 2
52
+ er[50:,:]=5
53
+ se = torch.zeros_like(er)
54
+ er.requires_grad_()
55
+ source_location=torch.tensor([[[10,10,0]]],device=device,dtype=torch.int)
56
+ receiver_location=torch.tensor([[[10,90,0]]],device=device,dtype=torch.int)
57
+ freq=2e8
58
+ peak_time = 1 / freq
59
+ source_amplitudes = torch.zeros((1,nt,1),device=device)
60
+ source_amplitudes[0,:,0]=DeepGPR.ricker(freq, nt, dt, peak_time).to(device)
61
+
62
+
63
+ #forward modeling
64
+ r = DeepGPR.compute(
65
+ device=device, dx=dx, dt=dt,
66
+ source_amplitudes=source_amplitudes,
67
+ source_location=source_location,
68
+ receiver_location=receiver_location,
69
+ er=er, se=se
70
+ )
71
+
72
+ (r[-1]**2).sum().backward()
73
+
74
+ _, ax = plt.subplots(1, 2, figsize=(10, 3))
75
+ ax[0].plot(r[-1].detach().flatten().cpu().numpy())
76
+ ax[0].set_title("Receiver data")
77
+ ax[1].imshow(er.grad.detach())
78
+ ax[1].set_title("Gradient")
79
+ plt.show()
80
+ ```
81
+
82
+ ![result](./Fig/example.png)
83
+
84
+ There are more examples in the ./examples.
85
+
86
+
87
+
88
+ The following figures present representative 2D and 3D full-waveform inversion (FWI) examples. For each case, the true model, initial model, and inverted result are shown to evaluate the reconstruction performance of the proposed method.
89
+
90
+ ### 2D FWI Result
91
+
92
+ The 2D example illustrates the inversion performance on a two-dimensional subsurface model. The comparison between the true model, initial model, and inverted result shows that the proposed method can effectively recover the main structural features from the initial model.
93
+
94
+ | True Model | Initial Model | Inverted Result |
95
+ |---|---|---|
96
+ | ![2D true model](./Fig/2dfwitrue.png) | ![2D initial model](./Fig/2dfwiinit.png) | ![2D inverted result](./Fig/2dfwipred.png) |
97
+
98
+ ### 3D FWI Result
99
+
100
+ The 3D example demonstrates the applicability of the proposed method to three-dimensional full-waveform inversion. For visualization, the figures below show the central slice of the 3D model, including the true model, the initial model, and the inverted result. The comparison indicates that the proposed method can reconstruct the dominant subsurface structures in the 3D case and improve the model consistency relative to the initial model.
101
+
102
+ | Model Type | Central Slice of 3D Model |
103
+ |---|---|
104
+ | True Model | ![3D true model central slice](./Fig/3dfwitrue.png) |
105
+ | Initial Model | ![3D initial model central slice](./Fig/3dfwiinit.png) |
106
+ | Inverted Result | ![3D inverted result central slice](./Fig/3dfwipred.png) |
107
+
108
+ # `compute` Interface Documentation
109
+
110
+ `compute` is a core function for 3D/2D Finite-Difference Time-Domain (FDTD) forward modeling, primarily designed for Ground Penetrating Radar (GPR) and electromagnetic wave propagation. It fully supports backpropagation (e.g., for Full Waveform Inversion, FWI) utilizing PyTorch's `autograd` engine.
111
+
112
+ ## 📝 Function Signature
113
+
114
+ ```python
115
+ def compute(device, dx=None, dt=None,
116
+ source_amplitudes=None,
117
+ source_location=None,
118
+ receiver_location=None,
119
+ er=None, se=None, mr=None,
120
+ E=None, H=None, PML=None,
121
+ pmlthick=10, source_direction=2, reciever_direction=2,
122
+ model_gradient_sampling_interval=1,
123
+ use_async_offload=False):
124
+ ```
125
+ ## 📥 Input Parameters
126
+ ### 1. Basic Physics & Grid Parameters
127
+
128
+ | Parameter | Data Type | Description |
129
+ | :--- | :--- | :--- |
130
+ | **`device`** | `torch.device` / `str` | PyTorch computation device, e.g., `'cuda:0'`. Determines where the computation takes place. |
131
+ | **`dx`** | `float` | Spatial grid step size (assuming an isotropic grid, i.e., $dx = dy = dz$). Typically in meters (m). |
132
+ | **`dt`** | `float` | Time step size. **Note**: Must strictly satisfy the CFL (Courant-Friedrichs-Lewy) stability condition, or an exception will be raised. Typically in seconds (s). |
133
+ ### 2. Medium Model Parameters
134
+
135
+ This section defines the electromagnetic properties of the simulation space. For 2D simulations, set `nz=1`.
136
+
137
+ | Parameter | Data Type | Shape | Description |
138
+ | :--- | :--- | :--- | :--- |
139
+ | **`er`** | `Tensor` (float) | `(nx, ny, nz)` or `(nx, ny)` | Relative permittivity ($\epsilon_r$). Values must be $\ge 1$. |
140
+ | **`se`** | `Tensor` (float) | `(nx, ny, nz)` or `(nx, ny)` | Electrical conductivity ($\sigma$). Values must be non-negative. |
141
+ | **`mr`** | `Tensor` (float) | `(nx, ny, nz)` or `(nx, ny)` | Relative permeability ($\mu_r$). Optional; defaults to 1 for the entire space. Shape must match `er`. |
142
+
143
+ > **Dimension Key**: `nx`, `ny`, and `nz` represent the number of grid cells along the X, Y, and Z axes, respectively.
144
+
145
+ ### 3. Source & Receiver Setup
146
+
147
+ This section defines the geometric observation system (coordinates) and the excitation waveforms.
148
+
149
+ | Parameter | Data Type | Shape | Description |
150
+ | :--- | :--- | :--- | :--- |
151
+ | **`source_amplitudes`** | `Tensor` (float) | `(num_waveforms, nt)` | Source excitation waveforms. `nt` is the total number of time steps.<br>- If `num_waveforms == 1`: All sources share this single waveform.<br>- If `num_waveforms == nsr`: Each source uses its corresponding waveform. |
152
+ | **`source_location`** | `Tensor` (int) | `(nstep, nsr, 3)` | Grid coordinate indices of the sources.<br>The last dimension corresponds to `[x_idx, y_idx, z_idx]`. |
153
+ | **`receiver_location`** | `Tensor` (int) | `(nstep, nrx, 3)` | Grid coordinate indices of the receivers.<br>The last dimension corresponds to `[x_idx, y_idx, z_idx]`. |
154
+ | **`source_direction`** | `int` | Scalar | Polarization direction/component of the source excitation.<br>`0` = X, `1` = Y, `2` = Z (e.g., exciting $E_z$). |
155
+ | **`reciever_direction`** | `int` | Scalar | The component direction recorded by the receivers. (Note: typo in variable name is kept as-is to match code).<br>`0` = $E_x$, `1` = $E_y$, `2` = $E_z$. |
156
+
157
+ > **Core Shape Definitions**:
158
+ > * `nstep`: Number of shots/batches (independent simulation tasks running in parallel).
159
+ > * `nsr`: Number of **sources** per single simulation.
160
+ > * `nrx`: Number of **receivers** per single simulation.
161
+ > * `nt`: Total number of time steps to simulate.
162
+
163
+ ### 4. Boundary Conditions & Optimization
164
+
165
+ | Parameter | Data Type | Format | Description |
166
+ | :--- | :--- | :--- | :--- |
167
+ | **`pmlthick`** | `int` / `list` / `Tensor`| Scalar or list of 6 | Thickness (in grid layers) of the PML (Perfectly Matched Layer) absorbing boundaries.<br>- Integer `p`: All six boundaries have thickness `p` (Z-boundaries are ignored in 2D).<br>- List `[x0, xm, y0, ym, z0, zm]`: Specific thicknesses for the 6 boundaries. |
168
+ | **`model_gradient_sampling_interval`**| `int` | Scalar | Wavefield sampling interval during forward propagation (Default: 1).<br>A larger integer reduces the VRAM usage for the saved `Eall` tensor, but may decrease the accuracy of backpropagated gradients. |
169
+ | **`use_async_offload`** | `bool` | Scalar | VRAM optimization flag (Default: `False`).<br>If `True`, the internal full wavefield tensor (`Eall`) is asynchronously offloaded to page-locked host memory (`pin_memory` CPU RAM). This drastically reduces GPU VRAM consumption at the cost of slightly slower computation times due to PCIe data transfer latency. |
170
+
171
+ ### 5. Field Variable States (Checkpoints / Initial Fields)
172
+
173
+ For starting a forward simulation from scratch ($t=0$), these three parameters should be passed as `None` (the system will automatically initialize zero-tensors).
174
+
175
+ | Parameter | Data Type | Shape | Description |
176
+ | :--- | :--- | :--- | :--- |
177
+ | **`E`** | `tuple` / `None` | 3 Tensors | Initial state of the electric field components `(Ex, Ey, Ez)`. Each tensor shape is `(nstep, nx+1, ny+1, nz+1)`. |
178
+ | **`H`** | `tuple` / `None` | 3 Tensors | Initial state of the magnetic field components `(Hx, Hy, Hz)`. Shapes identical to `E`. |
179
+ | **`PML`** | `tuple` / `None` | 24 Tensors | Auxiliary state variables ($\Phi$ fields) for the PML boundary updates. |
180
+
181
+ ---
182
+
183
+ ## 📤 Return Values
184
+
185
+ The function returns a tuple of 5 elements. These are used to extract synthetic data, initiate the gradient flow for backpropagation, or serve as initial parameters (`E`, `H`, `PML`) for subsequent time-stepped calculations.
186
+
187
+ ```python
188
+ return Eall, (Ex, Ey, Ez), (Hx, Hy, Hz), (x0EPhi1...zmHPhi2), receiver_amplitudes
189
+ ```
190
+
191
+ 1. **`Eall`**: The global electric field history saved for gradient calculation.
192
+ * **Shape**: `(nt_saved, nstep, nx, ny, nz)` (where `nt_saved` depends on `nt` and `model_gradient_sampling_interval`).
193
+ 2. **`(Ex, Ey, Ez)`**: The 3D electric field state at the final time step.
194
+ 3. **`(Hx, Hy, Hz)`**: The 3D magnetic field state at the final time step.
195
+ 4. **`(PML_Tuple)`**: A tuple of 24 Tensors recording the final time step state of the PML auxiliary $\Phi$ variables.
196
+ 5. **`receiver_amplitudes`**: **The core output.** The waveform signals recorded by the receivers over the entire simulation time.
197
+ * **Shape**: `(nstep, nt, nrx)`
198
+ * **Meaning**: `[Shot Index, Time Step, Receiver Index]`. Note that this output is already sliced to extract only the component specified by `reciever_direction`.
199
+
200
+
201
+ # Cite information
202
+ If you find our codes useful, please kindly cite this article. Thanks.
203
+
204
+ @article{liu2026fast,
205
+
206
+ title={Fast ground penetrating radar dual-parameter full waveform inversion method accelerated by hybrid compilation of CUDA kernel function and PyTorch},
207
+
208
+ author={Liu, Lei and Song, Chao and He, Liangsheng and Wang, Silin and Feng, Xuan and Liu, Cai},
209
+ journal={Computers \& Geosciences},
210
+
211
+ pages={106101},
212
+
213
+ year={2026},
214
+
215
+ publisher={Elsevier}
216
+
217
+ }
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=70", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "DeepGPR"
7
+ version = "0.0.9"
8
+ authors = [
9
+ { name = "Lei Liu", email = "liulei990222@gmail.com" }
10
+ ]
11
+ description = "PyTorch and CUDA for GPR FWI"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: Microsoft :: Windows",
18
+ "Operating System :: POSIX :: Linux",
19
+ "Topic :: Scientific/Engineering",
20
+ "Topic :: Scientific/Engineering :: Physics"
21
+ ]
22
+
23
+ dependencies = [
24
+ "numpy",
25
+ "scipy",
26
+ "matplotlib",
27
+ "torch"
28
+ ]
29
+
30
+ [tool.setuptools]
31
+ package-dir = { "" = "src" }
32
+ include-package-data = true
33
+
34
+ [tool.setuptools.packages.find]
35
+ where = ["src"]
36
+
37
+ [tool.setuptools.package-data]
38
+ DeepGPR = [
39
+ "lib/*.cu",
40
+ "lib/*.cuh",
41
+ "lib/*.h",
42
+ "lib/*.hpp",
43
+ "lib/*.cpp",
44
+ "lib/*.c",
45
+ "lib/*.dll",
46
+ "lib/*.so",
47
+ "lib/*.pyd"
48
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,140 @@
1
+ import ctypes
2
+ import os
3
+ import subprocess
4
+ import platform
5
+ from pathlib import Path
6
+
7
+
8
+ system_name = platform.system()
9
+ lib_dir = Path(__file__).parent / 'lib'
10
+ cu_file = lib_dir / 'deepgpr.cu'
11
+
12
+ if system_name == "Windows":
13
+ lib_extension = ".dll"
14
+ lib_filename = f'deepgpr{lib_extension}'
15
+ lib_path_obj = lib_dir / lib_filename
16
+
17
+ nvcc_cmd = [
18
+ 'nvcc', '-shared',
19
+ '-o', str(lib_path_obj),
20
+ str(cu_file)
21
+ ]
22
+ else:
23
+ lib_extension = ".so"
24
+ lib_filename = f'deepgpr{lib_extension}'
25
+ lib_path_obj = lib_dir / lib_filename
26
+
27
+ nvcc_cmd = [
28
+ 'nvcc', '-shared', '-Xcompiler', '-fPIC',
29
+ '-D_GLIBCXX_USE_CXX11_ABI=0',
30
+ '-o', str(lib_path_obj),
31
+ str(cu_file)
32
+ ]
33
+
34
+ if not lib_path_obj.is_file():
35
+ print(f'Compiling CUDA extension for {system_name} directly via nvcc...')
36
+ try:
37
+ subprocess.run(nvcc_cmd, check=True)
38
+ except FileNotFoundError:
39
+ raise RuntimeError(
40
+ "Compilation failed: 'nvcc' command not found. "
41
+ "Please ensure NVIDIA CUDA Toolkit is installed and 'nvcc' is added to your system PATH."
42
+ )
43
+ except subprocess.CalledProcessError as e:
44
+ raise RuntimeError(f"Compilation failed with error code {e.returncode}.")
45
+
46
+ lib_path = str(lib_path_obj)
47
+ c_lib = ctypes.cdll.LoadLibrary(lib_path)
48
+
49
+
50
+ c_lib.forward.argtypes = [
51
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
52
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
53
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
54
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
55
+ ctypes.POINTER(ctypes.c_float),
56
+ ctypes.POINTER(ctypes.c_float),
57
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
58
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
59
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
60
+
61
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
62
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
63
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
64
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
65
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
66
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
67
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
68
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
69
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
70
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
71
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
72
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
73
+
74
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
75
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
76
+
77
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
78
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
79
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
80
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
81
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
82
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
83
+
84
+ ctypes.c_float,ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_float,
85
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
86
+ ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
87
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
88
+ ctypes.c_int, ctypes.c_int
89
+ ]
90
+ c_lib.forward.restype = None
91
+
92
+ c_lib.backward.argtypes = [
93
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
94
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
95
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
96
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
97
+ ctypes.POINTER(ctypes.c_float),
98
+ ctypes.POINTER(ctypes.c_float),
99
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
100
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
101
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),#16
102
+
103
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
104
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
105
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
106
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
107
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
108
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
109
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
110
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
111
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
112
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
113
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
114
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),#40
115
+
116
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
117
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
118
+
119
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
120
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
121
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
122
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
123
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
124
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float), #58
125
+
126
+ ctypes.c_float,ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_float,
127
+ ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
128
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
129
+ ctypes.c_int ,ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
130
+ ctypes.c_int, ctypes.c_int , ctypes.c_int
131
+ ]
132
+
133
+ c_lib.backward.restype = None
134
+ __all__ = ['c_lib']
135
+
136
+
137
+ from .common import *
138
+ from .compute2 import *
139
+ from .multiscale import *
140
+ from .wavelet import *
@@ -2,13 +2,6 @@
2
2
  #include <iostream>
3
3
  #include <stdio.h>
4
4
  #include <cfloat>
5
- #include <cstdlib>
6
-
7
- #ifdef _WIN32
8
- #define DEEPGPR_API extern "C" __declspec(dllexport)
9
- #else
10
- #define DEEPGPR_API extern "C" __attribute__((visibility("default")))
11
- #endif
12
5
 
13
6
  __constant__ float e0 = 8.8541878128e-12;
14
7
  __constant__ float m0 = 1.25663706212e-06;
@@ -605,7 +598,9 @@ __global__ void accumulate_gradients(
605
598
  }
606
599
 
607
600
 
608
- DEEPGPR_API void forward(const float* __restrict__ er, const float* __restrict__ se, const float* __restrict__ mr,
601
+ extern "C" {
602
+
603
+ void forward(const float* __restrict__ er, const float* __restrict__ se, const float* __restrict__ mr,
609
604
  float* __restrict__ Eall_ptr,
610
605
  float* __restrict__ Ex, float* __restrict__ Ey, float* __restrict__ Ez,
611
606
  float* __restrict__ Hx, float* __restrict__ Hy, float* __restrict__ Hz,
@@ -707,7 +702,7 @@ DEEPGPR_API void forward(const float* __restrict__ er, const float* __restrict__
707
702
  }
708
703
  }
709
704
 
710
- DEEPGPR_API void backward(const float* __restrict__ er, const float* __restrict__ se, const float* __restrict__ mr,
705
+ void backward(const float* __restrict__ er, const float* __restrict__ se, const float* __restrict__ mr,
711
706
  const float* __restrict__ Eall_ptr,
712
707
  float* __restrict__ Ex, float* __restrict__ Ey, float* __restrict__ Ez,
713
708
  float* __restrict__ Hx, float* __restrict__ Hy, float* __restrict__ Hz,
@@ -820,4 +815,6 @@ DEEPGPR_API void backward(const float* __restrict__ er, const float* __restrict_
820
815
  cudaStreamDestroy(stream_comp);
821
816
  cudaStreamDestroy(stream_trans);
822
817
  }
818
+ }
819
+
823
820
  }
Binary file
@@ -1,16 +1,19 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
- Author-Email: Lei Liu <liulei990222@gmail.com>
5
+ Author-email: Lei Liu <liulei990222@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
7
7
  Classifier: Operating System :: Microsoft :: Windows
8
8
  Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Topic :: Scientific/Engineering
10
+ Classifier: Topic :: Scientific/Engineering :: Physics
9
11
  Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
10
13
  Requires-Dist: numpy
11
14
  Requires-Dist: scipy
12
15
  Requires-Dist: matplotlib
13
- Description-Content-Type: text/markdown
16
+ Requires-Dist: torch
14
17
 
15
18
  # DeepGPR
16
19
 
@@ -33,40 +36,10 @@ Supports techniques such as checkpointing, DDP, and the utilization of CPU memor
33
36
  ## System Requirements
34
37
 
35
38
  - **OS**: Linux and Windows
36
- - **Python**: Python 3.8+
37
- - **GPU**: NVIDIA GPU with sufficient VRAM for 2D/3D computational grids
38
- - **CUDA**: NVIDIA driver and CUDA Toolkit
39
- - **Libraries**:
40
- - `torch` with CUDA support
41
- - `numpy`
42
- - `scipy`
43
- - `matplotlib`
44
-
45
- ### Additional Requirements for Building from Source
46
-
47
- DeepGPR contains a CUDA backend that is compiled during installation. Therefore, users who install the package from source need a working CUDA/C++ build environment.
48
-
49
- #### Linux
50
-
51
- - CUDA Toolkit with `nvcc`
52
- - GCC/G++ compiler compatible with the installed CUDA version
53
- - CMake 3.23 or later
39
+ - **Environment**: Python 3.8+, CUDA Toolkit
40
+ - **Libraries**: `torch` (with CUDA support), `numpy`, `scipy`, `matplotlib`
41
+ - **Hardware**: NVIDIA GPU with sufficient VRAM for 3D computational grids.
54
42
 
55
- #### Windows
56
-
57
- - CUDA Toolkit with `nvcc`
58
- - CMake 3.23 or later
59
- - Microsoft Visual Studio Build Tools or Visual Studio Community
60
- - The **Desktop development with C++** workload
61
- - MSVC C++ compiler `cl.exe`
62
- - Windows SDK
63
- - Optional: `ninja`
64
-
65
- On Windows, `nvcc` relies on the MSVC compiler to build CUDA code. Please make sure that both `nvcc` and `cl.exe` are available before running:
66
-
67
- ```bash
68
- pip install .
69
- ```
70
43
 
71
44
  ## Start
72
45
 
@@ -258,4 +231,4 @@ If you find our codes useful, please kindly cite this article. Thanks.
258
231
 
259
232
  publisher={Elsevier}
260
233
 
261
- }
234
+ }
@@ -0,0 +1,14 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/DeepGPR/__init__.py
4
+ src/DeepGPR/common.py
5
+ src/DeepGPR/compute2.py
6
+ src/DeepGPR/multiscale.py
7
+ src/DeepGPR/wavelet.py
8
+ src/DeepGPR.egg-info/PKG-INFO
9
+ src/DeepGPR.egg-info/SOURCES.txt
10
+ src/DeepGPR.egg-info/dependency_links.txt
11
+ src/DeepGPR.egg-info/requires.txt
12
+ src/DeepGPR.egg-info/top_level.txt
13
+ src/DeepGPR/lib/deepgpr.cu
14
+ src/DeepGPR/lib/deepgpr.so
@@ -0,0 +1,4 @@
1
+ numpy
2
+ scipy
3
+ matplotlib
4
+ torch
@@ -0,0 +1 @@
1
+ DeepGPR
deepgpr-0.0.8/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- lib/deepgpr.so
2
- __pycache__/
3
- dist/
4
- build/
5
- .vscode/
6
- *.egg-info/
7
- pyproject.toml