• Stars
    star
    201
  • Rank 194,491 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Integrating the TensorFlow 1.15 C-API into OpenFOAM 5.0 for data-driven CFD algorithm development

TensorFlowFoam

A turbulence model built using a deep neural network trained in Tensorflow 1.15.

Contents

  1. ML_RANS/: A tutorial for setting up an artificial neural network surrogate for a linear eddy-viscosity RANS model.

  2. ML_LES/: A tutorial for setting up an artificial neural network surrogate for dynamic Smagorinsky coefficient calculation (i.e., bypass test-filtering).

  3. IN_SITU/: A tutorial for setting up a neural network training from within OpenFOAM to avoid disk IO. NOTE: We have observed some training instances to suffer from segfaults due to impromper initial (randomized) choices for weights and biases (be careful).

Installation

The following steps will get you started with a data-driven turbulence model deployed in OpenFOAM 5. I am assuming you have already installed and successfully run OpenFOAM 5 prior to this. Also, this tutorial will be based on Linux (Ubuntu 18.04) at this point of time.

Step 1: Install python environment

We suggest the creation of a new Python 3.6.9 virtual environment (either in conda or venv) and the installation of relevant packages for this tutorial using

pip install -r requirements.txt

Step 2: Download the Tensorflow C API

You can download the TensorFlow C API at https://www.tensorflow.org/install/lang_c. Follow instructions there to install on your machine. This tutorial/model is designed for the Linux CPU only release. Briefly, the instructions to install (if you have root access) are:

  1. sudo tar -C /usr/local -xzf (downloaded file)
  2. sudo ldconfig

and you are good to go. If you do not have root access and need to place the TensorFlow C API at an arbitrary location you may use the following steps:

  1. tar -C /path/to/api -xzf (downloaded file)
  2. export LIBRARY_PATH=$LIBRARY_PATH:/path/to/api/lib
  3. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/api/lib

Note that steps 2 and 3 either need to be added to your .bashrc file or need to be executed each time a new terminal session is started.

Update: The new version of the C API are for TensorFlow 2.4 and have not been tested with the contents of this repository. You may obtain the C API tarball for 1.15 in misc/.

Step 3: Test that C API is running using Test_TF_C code

After Step 2 is complete test that your API is configured correctly by executing the following code (which you can save in hello_tf.cpp

//Working on some tensorflow and c++ implementations

#include <stdio.h>
#include <tensorflow/c/c_api.h>

int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());

  return 0;
}

by using

  1. g++ hello_tf.cpp -ltensorflow
  2. ./a.out to obtain the following output
Hello from TensorFlow C library version 1.15.0

If you face an error here (perhaps due to not linking appropriately in the absence of root priveleges) try using:

g++ -I/path/to/api/include -L/path/to/api/lib hello_tf.cpp -ltensorflow

for step 2.

If you have reached this point - congratulations you are ready to use TensorFlow 1.15 within OpenFOAM 5. You may utilize the individual READMEs from ML_RANS/, ML_LES and IN-SITU (documentation for the latter two are in-progress) to construct a neural network based turbulence model for training/deployment in OpenFOAM.

Points of contact for further assistance - Romit Maulik ([email protected]), Himanshu Sharma ([email protected]), Saumil Patel ([email protected]). This work was performed by using the resources of the Argonne Leadership Computing Facility, a U.S. Department of Energy (Office of Science) user facility at Argonne National Laboratory, Lemont, IL, USA.

If you have found this framework informative and useful for any of your research, please cite us

@inproceedings{maulik2021deploying,
  title={Deploying deep learning in OpenFOAM with TensorFlow},
  author={Maulik, Romit and Sharma, Himanshu and Patel, Saumil and Lusch, Bethany and Jennings, Elise},
  booktitle={AIAA Scitech 2021 Forum},
  pages={1485},
  year={2021}
}

LICENSE

MIT

More Repositories

1

ai-science-training-series

Jupyter Notebook
205
star
2

PythonFOAM

In-situ data analyses and machine learning with OpenFOAM and Python
C++
161
star
3

balsam

High throughput workflows and automation for HPC
Python
76
star
4

dlio_benchmark

An I/O benchmark for deep Learning applications
Python
62
star
5

ALCF_Hands_on_HPC_Workshop

The ALCF hosts a regular simulation, data, and learning workshop to help users scale their applications. This repository contains the examples used in the workshop.
HTML
54
star
6

CompPerfWorkshop

ALCF Computational Performance Workshop
Python
34
star
7

ATPESC_MachineLearning

Lecture and hands-on material for Track 8- Machine Learning of Argonne Training Program on Extreme-Scale Computing
LLVM
32
star
8

molan

Data analytics for molecular solids melting points
Jupyter Notebook
26
star
9

active-learning-md

Active learning workflow developed as a part of the upcoming article "Machine Learning Inter-Atomic Potentials Generation Driven by Active Learning: A Case Study for Amorphous and Liquid Hafnium dioxide"
Python
25
star
10

ALCFBeginnersGuide

Cuda
24
star
11

llm-workshop

Jupyter Notebook
23
star
12

AI4ScienceTutorial

A tutorial for students that surveys basic ML techniques in ipython notebook format.
Jupyter Notebook
22
star
13

THAPI

A tracing infrastructure for heterogeneous computing applications.
C
22
star
14

user-guides

ALCF Systems User Documentation
HTML
20
star
15

GettingStarted

Collection of small examples for running on ALCF resources
C
16
star
16

AIaccelerators-SC23-tutorial

AI Accelerators-SC23-tutorial Repository
Jupyter Notebook
11
star
17

HPC-Patterns

Provide examples on how to use GPU with Parallel Programing Paradigm (MPI, OpenMP, SYCL)
C++
10
star
18

AIaccelerators-SC22-tutorial

AI Accelerator Tutorial SC22
Python
8
star
19

alcl

Argonne Leadership Computing Facility OpenCL tutorial
C
8
star
20

alcf-nccl-tests

NCCL tests for ALCF machines
Roff
7
star
21

alcf4_benchmarks

Repository for ALCF-4 Benchmarks as defined in the RFP.
6
star
22

copper

scalable data movement in Exascale Supercomputers
C++
6
star
23

ThetaGPU-Docs

Staging area for Theta-GPU documentation
Python
5
star
24

SimAI-Bench

ALCF benchmarks for coupled simulation and AI workflows
Python
4
star
25

summer-school-2024

4
star
26

pbs_utils

scripts for working with PBS
Shell
4
star
27

SyclCPLX

Sycl complex library header-only
C++
4
star
28

ai-testbed-userdocs

AI-Testbed at ALCF provides an infrastructure for the next-generation of AI-accelerator machines.
HTML
4
star
29

nexus

Scripts and tools for IRI applications at ALCF
Python
4
star
30

checkpoint_restart

This repo is for providing instructions on how to do checkpoint/restart at large scale simulations on exasscale machines
Shell
3
star
31

dlSoftwareTests

Simple tests to verify ML/DL environments on ALCF HPC resources are working correctly.
Python
3
star
32

DL-Profiling-Examples

Example scripts and profiling demonstrations for deep learning models
Python
3
star
33

THAPI-spack

This is a spack environment for THAPI.
Python
3
star
34

AIAccelerators-AE

AD/AE repo for the paper on AI Accelerator Evaluation
Python
3
star
35

IntroSYCLtutorial

Jupyter Notebook
2
star
36

dlio_ml_workloads

Reference workloads for DLIO Benchmark
Python
2
star
37

CCS

CCS (C Configuration Space and Tuning Library) aims at providing interoperability between autotuning frameworks and applications with auto-tuning needs. It does so by providing a C interface to describe autotuning problems and autotuners.
C
2
star
38

autoperf

Core autoperf source
C
2
star
39

polaris-userdocs

Temporary documentation for Polaris resource
HTML
2
star
40

LLM-Inference-Bench

LLM-Inference-Bench
Jupyter Notebook
2
star
41

conda_install_scripts

Some install scripts for miniconda that include tensorflow and keras in the intel channel.
Shell
2
star
42

mlprof

Profiling tools for performance studies of competing ML frameworks on HPC systems
Python
2
star
43

container-registry

Contains images and recipes to run container images on Theta, ThetaGPU, Polaris and Sunspot
Python
2
star
44

dl_scaling

Scaling Deep learning on HPC systems
Python
2
star
45

alcf-osu-benchmarks

OSU benchmarks on ALCF systems
Roff
1
star
46

scalable_conda_env

This is to show how to setup conda environment for large scale runs
Python
1
star
47

storage

storage benchmarks
C
1
star
48

inference-endpoints

This is a repository with examples to run inference endpoints on various ALCF clusters
Jupyter Notebook
1
star
49

tc-ipu

Implementation of triangle counting for Graphcore IPU
Emacs Lisp
1
star
50

balsam-serial-mode-profiling

Contains application tools and scripts for measuring balsam performance in serial mode.
Python
1
star
51

theta_conda_channel

Files for building anaconda cloud packages for Theta.
Shell
1
star
52

docker_image_recipes

A repository for image recipe files useful for ALCF systems.
Dockerfile
1
star
53

babeltrace2-ruby

Babeltrace2 Ruby bindings
Ruby
1
star
54

ALCF-AI-Testbed

HTML
1
star
55

cast-to-yaml

Extract information fom a c ast
Ruby
1
star