# PyTorchFWI **Repository Path**: askuasen/pytorch_fwi ## Basic Information - **Project Name**: PyTorchFWI - **Description**: This is a modified version by TorchFWI:https://github.com/lidongzh/TorchFWI in Github platform, which could help you run on windows 10. the orgin version only could run on linux. - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-02-14 - **Last Updated**: 2025-02-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # TorchFWI TorchFWI is an elastic full-waveform inversion (FWI) package integrated with the deep-learning framework PyTorch. On the one hand, it enables the integration of FWI with neural networks and makes it easy to create complex inversion workflows. On the other hand, the multi-GPU-accelerated FWI component with a boundary-saving method offers high computational efficiency. One can use the suite of built-in optimizers in PyTorch or Scipy (e.g., L-BFGS-B) for inversion. This is a modified version by [TorchFWI:https://github.com/lidongzh/TorchFWI](https://github.com/lidongzh/TorchFWI) in Github platform, which could help you run on windows 10. the orgin version only could run on linux. ## Requirement It's need to check the running environment. - Linux, Ubuntu 20.04 or Window 10 - CUDA 12.x and cudnn 8.X (CUDA 12.4 and cudnn 8.9.7.29). - Visual Studio 2022 and Its buildtools. - Python 3.10.11 - torch 2.X (recommend the version 2.5.0) - numpy>=1.26.4 - matplotlib>=3.10.0 - ninja>=1.11.1.3 - scipy>=1.14.1 ## Installing The build script **setup.py** to build cpp and cuda sources wrapper is in directory **ops/fwi**. There is a helper document in [README.md](ops/fwi/README.md) ## Running As a quick start, go to directory *src*, and type ``` python main.py --generate_data ``` Then, type ``` python main.py ``` to start inversion. You can for example add the `--ngpu` flag to use multiple GPUs for forward simulation or inversion. For example, ``` python main.py --ngpu=4 ``` The initial model and the inverted model after 80 iterations are shown below. This package uses just-in-time (JIT) compilation for the FWI code. It only compiles the first time you run the code, and no explicit ''make'' is required. An NVIDIA cuda compiler is needed. If you find this package helpful in your research, please kindly cite 1. **Dongzhuo Li**, **Kailai Xu**, Jerry M. Harris, and Eric Darve. [*Time-lapse Full-waveform Inversion for Subsurface Flow Problems with Intelligent Automatic Differentiation*](https://arxiv.org/abs/1912.07552). 2. **Dongzhuo Li**, **Jerry M. Harris**, **Biondo Biondi**, and **Tapan Mukerji**. 2019. [*Seismic full waveform inversion: nonlocal similarity, sparse dictionary learning, and time-lapse inversion for subsurface flow.*](http://purl.stanford.edu/ds556fq6692). 3. **Kailai Xu**, **Dongzhuo Li**, Eric Darve, and Jerry M. Harris. [*Learning Hidden Dynamics using Intelligent Automatic Differentiation*](http://arxiv.org/abs/1912.07547). The **FwiFlow** package, which uses TensorFlow as the backend with additional subsurface flow inversion capabilities, is [*here*](https://github.com/lidongzh/FwiFlow.jl). ## Project Structure ``` project_root_home/ ├── Mar_models/ # data │ ├── main.py │ ├── obj_wrapper.py │ └── main_modified.py ├── ops/ │ ├── fwi/ # Python module │ │ └── src/ # cuda code │ │ │ └── cuda_ext/ # cuda code │ │ │ └── torchfwi/ # cuda code │ │ │ | ├── ops.py # inculude FWIFunction, FWI, FWI_obscalc module │ │ │ | └── utils.py # │ │ ├── README.md # about installing fwi │ │ └── setup.py # build script │ └── __init__.py ├── src/ # Python code │ ├── main.py │ ├── obj_wrapper.py │ └── main_modified.py └── LICENSE # MIT LICENSE └── README.md # project information ``` ## Email orgin version author:[lidongzh@stanford.edu](mailto:lidongzh@stanford.edu) modified version author: [xbs150@163.com](mailto:xbs150@163.com)