Skip to content

Commit 1be82b6

Browse files
authored
Merge pull request #557 from deepmodeling/github-actions-selfhosted-runner
CI: Change actions to self-hosted runner.
2 parents 52b8a91 + 353eee2 commit 1be82b6

File tree

5 files changed

+41
-42
lines changed

5 files changed

+41
-42
lines changed

.github/workflows/CPU_inferencce_validation.yml

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,30 @@ on:
88
- master
99
jobs:
1010
build_validation:
11-
runs-on: [self-hosted, linux, x64]
11+
runs-on: [self-hosted, linux, x64, 4060Ti]
1212
if: github.repository_owner == 'deepmodeling'
13-
container:
14-
image: ubuntu:20.04
15-
options: --shm-size=5g # shared memory size = 5GB
1613
steps:
1714
- name: Checkout
1815
uses: actions/checkout@v3
19-
- name: install dependencies
20-
env:
21-
DEBIAN_FRONTEND: noninteractive
22-
run: |
23-
apt-get update
24-
apt-get install -y sudo wget unzip git software-properties-common make cmake g++ mpich openmpi-bin libopenmpi-dev libscalapack-mpi-dev vim git-core
25-
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
26-
sudo add-apt-repository http://dl.openfoam.org/ubuntu
27-
sudo apt-get update
28-
export DEBIAN_FRONTEND=noninteractive
29-
apt-get -y install openfoam7
30-
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
31-
bash Miniconda3-latest-Linux-x86_64.sh -b
32-
. ~/miniconda3/etc/profile.d/conda.sh
33-
conda create -n libcantera python=3.8
34-
conda activate libcantera
35-
conda install -c cantera libcantera-devel=2.6
36-
conda install -c cantera cantera
37-
conda install pytorch pybind11
38-
conda install pkg-config
39-
conda install --channel https://conda.anaconda.org/zhaofeng-shu33 easydict
40-
git clone https://github.com/deepmodeling/deepflame-dev.git
41-
cd deepflame-dev
4216

43-
4417
- name: build and validation with CPU inference
4518
env:
4619
OMPI_ALLOW_RUN_AS_ROOT: 1
4720
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
4821
OMPI_MCA_btl_vader_single_copy_mechanism: none
4922
run:
50-
/bin/bash -c " echo $PWD && ls $PWD
51-
&& wget --content-disposition https://aisquare.oss-us-east-1.aliyuncs.com/data/datasets/14b50df5-dbe9-4f1c-bf58-032b8bc40a20
52-
&& unzip flare_CH4_SandiaD_4D.zip
23+
/bin/bash -c " echo $PWD
5324
&& ls $PWD
54-
&& cp -r flare_CH4_SandiaD_4D.tbl examples/dfLowMachFoam/fgm/twoD_SandiaD_flareFGM
55-
&& source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc
56-
&& . configure.sh --use_pytorch&& source ./bashrc && . install.sh
57-
&& cd test && ./Allrun && conda deactivate "
25+
&& cp -r /root/actions-runner/data/flare_CH4_SandiaD_4D.tbl examples/dfLowMachFoam/fgm/twoD_SandiaD_flareFGM
26+
&& source ~/miniconda3/etc/profile.d/conda.sh
27+
&& conda activate libcantera
28+
&& source /opt/openfoam7/etc/bashrc
29+
&& . configure.sh --use_pytorch
30+
&& source ./bashrc
31+
&& . install.sh
32+
&& cd test
33+
&& ./Allrun
34+
&& conda deactivate "
5835

5936
- name: test
6037
run: |

examples/dfLowMachFoam/fgm/twoD_SandiaD_flareFGM/Allrun

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
cd ${0%/*} || exit 1 # Run from this directory
33

4-
if [ -e flare_CH4_SandiaD_4D.tbl]
4+
if [ -e flare_CH4_SandiaD_4D.tbl ]
55
then
66
echo "flare_CH4_SandiaD_4D.tbl exists. Make sure correct table has been used!"
77
else

test/Tu500K-Phi1/DNN_model.pt

100755100644
-47.6 MB
Binary file not shown.

test/Tu500K-Phi1/constant/CanteraTorchProperties

100755100644
File mode changed.

test/Tu500K-Phi1/inference.py

100755100644
Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import cantera as ct
66

77
device_main = "cuda:0"
8-
device_list = range(torch.cuda.device_count())
8+
device_list = [0] #range(torch.cuda.device_count())
99

1010
torch.set_printoptions(precision=10)
1111

@@ -95,16 +95,18 @@ def forward(self, x):
9595
Ymu2 = Ymu0
9696
Ystd2 = Ystd0
9797

98+
99+
"""
98100
#load model
99101
layers = [n_species +2, 1600, 800, 400, 1]
100-
102+
101103
model0list = []
102104
for i in range(n_species-1):
103105
model0list.append(NN_MLP(layers))
104106
105107
for i in range(n_species-1):
106108
model0list[i].load_state_dict(state_dict[f'net{i}'])
107-
109+
108110
109111
for i in range(n_species-1):
110112
model0list[i].eval()
@@ -113,7 +115,23 @@ def forward(self, x):
113115
if len(device_ids) > 1:
114116
for i in range(n_species-1):
115117
model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids)
118+
"""
119+
120+
#load model
121+
layers = [2+n_species]+[400]*4+[ n_species-1]
122+
# layers = [2+n_species]+[800,400,200,100]+[n_species-1]
123+
124+
125+
model = NN_MLP(layers)
126+
127+
model.load_state_dict(state_dict['net'])
128+
129+
model.eval()
130+
model.to(device=device)
116131

132+
if len(device_ids) > 1:
133+
model = torch.nn.DataParallel(model, device_ids=device_ids)
134+
117135
except Exception as e:
118136
print(e.args)
119137

@@ -126,6 +144,8 @@ def inference(vec0):
126144
'''
127145
vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho
128146
vec0[:,1] *= 101325
147+
# vec0[:,1] *= 0
148+
# vec0[:,1] += 101325
129149
mask = vec0[:,0] > frozenTemperature
130150
vec0_input = vec0[mask, :]
131151
print(f'real inference points number: {vec0_input.shape[0]}')
@@ -148,9 +168,11 @@ def inference(vec0):
148168
#inference
149169

150170
output0_normalized = []
151-
for i in range(n_species-1):
152-
output0_normalized.append(model0list[i](input0_normalized))
153-
output0_normalized = torch.cat(output0_normalized, dim=1)
171+
172+
#for i in range(n_species-1):
173+
# output0_normalized.append(model0list[i](input0_normalized))
174+
#output0_normalized = torch.cat(output0_normalized, dim=1)
175+
output0_normalized = model(input0_normalized)
154176

155177
# post_processing
156178
output0_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1]

0 commit comments

Comments
 (0)