Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f015ea1
fix bug of ndim when nframe==1
Jan 11, 2020
bb8bf21
Merge pull request #151 from amcadmus/master
amcadmus Jan 11, 2020
5f77019
fix bug of test data
Jan 22, 2020
815d716
fix bug of "-l-ldeepmd"
Jan 6, 2020
98ec02b
fix bug of undefined get_rcut and get_ntypes
Jan 22, 2020
3b82e23
do not upgrade pip
Jan 22, 2020
0f9edb4
Merge pull request #159 from amcadmus/master
amcadmus Jan 23, 2020
ac68881
fix bug of 0 output when sec_a.back() is lager than 1024
Jan 23, 2020
d1fa044
fix bug of 0 output when sec_a.back() is lager than 1024
Jan 23, 2020
984ef69
Merge pull request #162 from amcadmus/master
amcadmus Jan 23, 2020
0d1a3bc
fix bug #165
Jan 31, 2020
88da716
Merge pull request #166 from amcadmus/master
amcadmus Jan 31, 2020
cb25563
std should be set to 1 if its value vanishes
Feb 1, 2020
b29d6d3
protect the descrpt to 1e-2 rather than set to 1
Feb 1, 2020
07c42c1
Merge pull request #170 from amcadmus/master
amcadmus Feb 1, 2020
c8b1238
merge with stable commit 10e5780
May 23, 2020
e015eac
fix bug in test
May 23, 2020
bc01883
Merge pull request #226 from amcadmus/master
amcadmus May 23, 2020
567bcff
cmake is a requirement only if it's not installed
njzjz May 23, 2020
507062e
Update README.md
njzjz Sep 5, 2020
9dabb31
use GitHub docker container
njzjz Sep 6, 2020
e098369
Merge pull request #251 from njzjz/markdown
amcadmus Sep 7, 2020
b2662e2
Merge pull request #256 from deepmodeling/devel
amcadmus Sep 13, 2020
b00e29d
Merge pull request #24 from deepmodeling/master
denghuilu Sep 14, 2020
143afce
fix bug of error compilation when using float precision
Sep 14, 2020
30922e7
Merge pull request #257 from denghuilu/master
amcadmus Sep 14, 2020
5061492
global_polar: print loss not normalized by sqrt(natoms). add dp test …
Sep 16, 2020
e110ec4
correct way of getting site package path
Sep 17, 2020
59d780c
Merge pull request #258 from deepmodeling/r1.2
amcadmus Sep 17, 2020
45849aa
add ability to parse yaml config files
marian-code Oct 7, 2020
faae175
added script to convert json to yaml
marian-code Oct 7, 2020
9806168
added test for json yaml equality
marian-code Oct 8, 2020
865a1f4
minor bugfix
marian-code Oct 8, 2020
7dbe3e0
Merge pull request #25 from deepmodeling/master
denghuilu Oct 9, 2020
d248f8a
fix conflict between master and devel branch
Oct 9, 2020
b97c00b
Merge pull request #273 from denghuilu/master
amcadmus Oct 10, 2020
a461221
Merge branch 'master' into yaml_support
amcadmus Oct 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
- [Deep Potential in a nutshell](#deep-potential-in-a-nutshell)
- [Download and install](#download-and-install)
- [Easy installation methods](#easy-installation-methods)
- [Offline packages](#offline-packages)
- [With Docker](#with-docker)
- [With conda](#with-conda)
- [Offline packages](#offline-packages)
- [Install the python interaction](#install-the-python-interface)
- [Install the Tensorflow's python interface](#install-the-tensorflows-python-interface)
- [Install the DeePMD-kit's python interface](#install-the-deepmd-kits-python-interface)
Expand Down Expand Up @@ -90,8 +90,10 @@ Please follow our [github](https://github.com/deepmodeling/deepmd-kit) webpage t
## Easy installation methods
There various easy methods to install DeePMD-kit. Choose one that you prefer. If you want to build by yourself, jump to the next two sections.

### With Docker
A docker for installing the DeePMD-kit on CentOS 7 is available [here](https://github.com/frankhan91/deepmd-kit_docker).
After your easy installation, DeePMD-kit (`dp`) and LAMMPS (`lmp`) will be available to execute. You can try `dp -h` and `lmp -h` to see the help. `mpirun` is also available considering you may want to run LAMMPS in parallel.

### Offline packages
Both CPU and GPU version offline packages are avaiable in [the Releases page](https://github.com/deepmodeling/deepmd-kit/releases).

### With conda
DeePMD-kit is avaiable with [conda](https://github.com/conda/conda). Install [Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html) first.
Expand All @@ -101,13 +103,23 @@ To install the CPU version:
conda install deepmd-kit=*=*cpu lammps-dp=*=*cpu -c deepmodeling
```

To install the GPU version containing [CUDA 10.0](https://docs.nvidia.com/deploy/cuda-compatibility/index.html#binary-compatibility__table-toolkit-driver):
To install the GPU version containing [CUDA 10.1](https://docs.nvidia.com/deploy/cuda-compatibility/index.html#binary-compatibility__table-toolkit-driver):
```bash
conda install deepmd-kit=*=*gpu lammps-dp=*=*gpu -c deepmodeling
```

### Offline packages
Both CPU and GPU version offline package are avaiable in [the Releases page](https://github.com/deepmodeling/deepmd-kit/releases).
### With Docker
A docker for installing the DeePMD-kit is available [here](https://github.com/orgs/deepmodeling/packages/container/deepmd-kit).

To pull the CPU version:
```bash
docker pull ghcr.io/deepmodeling/deepmd-kit:1.2.0_cpu
```

To pull the GPU version:
```bash
docker pull ghcr.io/deepmodeling/deepmd-kit:1.2.0_cuda10.1_gpu
```

## Install the python interface
### Install the Tensorflow's python interface
Expand Down
37 changes: 37 additions & 0 deletions data/json/json2yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

import argparse
import json
from pathlib import Path
from warnings import warn

import yaml


def _main():
parser = argparse.ArgumentParser(
description="convert json config file to yaml",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

# get all json files in dir
jsons = [p for p in Path.cwd().glob("*.json")]
# use the newest as autosuggestion
jsons.sort(key=lambda x: x.stat().st_mtime, reverse=True)
jfile = jsons[0]
yfile = jfile.with_suffix(".yaml")

parser.add_argument("INPUT", default=jfile, type=Path, nargs="?",
help="input json file")
parser.add_argument("OUTPUT", default=yfile, type=Path, nargs="?",
help="output yaml file")
args = parser.parse_args()

with args.INPUT.open("r") as infile, args.OUTPUT.open("w") as outfile:
yaml.dump(json.load(infile), outfile, default_flow_style=False,
sort_keys=False)

warn("The order of the keys won't be preserved!", SyntaxWarning)
warn("_comment keys will also be lostt in the conversion")

if __name__ == "__main__":
_main()
18 changes: 3 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@
from setuptools_scm import get_version
from packaging.version import LegacyVersion
from os import path, makedirs
import imp, sys, platform
import os, imp, sys, platform, sysconfig

def get_dp_install_path() :
site_packages_path = path.join(path.dirname(path.__file__), 'site-packages')
dp_scm_version = get_version(root="./", relative_to=__file__)
python_version = 'py' + str(sys.version_info.major + sys.version_info.minor * 0.1)
os_info = sys.platform
machine_info = platform.machine()
dp_pip_install_path = site_packages_path + '/deepmd'
dp_setup_install_path = site_packages_path + '/deepmd_kit-' + dp_scm_version + '-' + python_version + '-' + os_info + '-' + machine_info + '.egg/deepmd'

return dp_pip_install_path, dp_setup_install_path

readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md')
try:
Expand All @@ -31,7 +21,8 @@ def get_dp_install_path() :
site_packages_path = path.join(path.dirname(path.__file__), 'site-packages')
tf_install_dir = imp.find_module('tensorflow', [site_packages_path])[1]

install_requires=['numpy', 'scipy']

install_requires=['numpy', 'scipy', 'pyyaml']
setup_requires=['setuptools_scm', 'scikit-build', 'cmake']

# add cmake as a build requirement if cmake>3.0 is not installed
Expand All @@ -46,7 +37,6 @@ def get_dp_install_path() :
except OSError:
pass

dp_pip_install_path, dp_setup_install_path = get_dp_install_path()

setup(
name="deepmd-kit",
Expand All @@ -70,8 +60,6 @@ def get_dp_install_path() :
'-DBUILD_PY_IF:BOOL=TRUE',
'-DBUILD_CPP_IF:BOOL=FALSE',
'-DFLOAT_PREC:STRING=high',
'-DDP_PIP_INSTALL_PATH=%s' % dp_pip_install_path,
'-DDP_SETUP_INSTALL_PATH=%s' % dp_setup_install_path,
],
cmake_source_dir='source',
cmake_minimum_required_version='3.0',
Expand Down
2 changes: 1 addition & 1 deletion source/op/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif (BUILD_CPP_IF)

if (BUILD_PY_IF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH DESTINATION ${DP_PIP_INSTALL_PATH} ${DP_SETUP_INSTALL_PATH} ${CMAKE_BINARY_DIR}/op/cuda)
set(CMAKE_INSTALL_RPATH $ORIGIN)
if (USE_CUDA_TOOLKIT)
add_library(op_abi SHARED ${OP_PY_CUDA_SRC} ${OP_LIB})
add_library(op_grads SHARED ${OP_GRADS_SRC})
Expand Down
54 changes: 28 additions & 26 deletions source/op/cuda/descrpt_se_a.cu
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ __device__ inline T dev_dot(T * arr1, T * arr2) {
return arr1[0] * arr2[0] + arr1[1] * arr2[1] + arr1[2] * arr2[2];
}

__device__ inline void spline5_switch(compute_t & vv,
compute_t & dd,
compute_t & xx,
const compute_t & rmin,
const compute_t & rmax)
template<typename FPTYPE>
__device__ inline void spline5_switch(FPTYPE & vv,
FPTYPE & dd,
FPTYPE & xx,
const float & rmin,
const float & rmax)
{
if (xx < rmin) {
dd = 0;
vv = 1;
}
else if (xx < rmax) {
compute_t uu = (xx - rmin) / (rmax - rmin) ;
compute_t du = 1. / (rmax - rmin) ;
FPTYPE uu = (xx - rmin) / (rmax - rmin) ;
FPTYPE du = 1. / (rmax - rmin) ;
vv = uu*uu*uu * (-6 * uu*uu + 15 * uu - 10) + 1;
dd = ( 3 * uu*uu * (-6 * uu*uu + 15 * uu - 10) + uu*uu*uu * (-12 * uu + 15) ) * du;
}
Expand Down Expand Up @@ -180,20 +181,21 @@ __global__ void format_nlist_fill_b_se_a(int * nlist,
}
//it's ok!

__global__ void compute_descriptor_se_a (VALUETYPE* descript,
template<typename FPTYPE>
__global__ void compute_descriptor_se_a (FPTYPE* descript,
const int ndescrpt,
VALUETYPE* descript_deriv,
FPTYPE* descript_deriv,
const int descript_deriv_size,
VALUETYPE* rij,
FPTYPE* rij,
const int rij_size,
const int* type,
const VALUETYPE* avg,
const VALUETYPE* std,
const FPTYPE* avg,
const FPTYPE* std,
int* nlist,
const int nlist_size,
const VALUETYPE* coord,
const VALUETYPE rmin,
const VALUETYPE rmax,
const FPTYPE* coord,
const float rmin,
const float rmax,
const int sec_a_size)
{
// <<<nloc, sec_a.back()>>>
Expand All @@ -204,24 +206,24 @@ __global__ void compute_descriptor_se_a (VALUETYPE* descript,
if (idy >= sec_a_size) {return;}

// else {return;}
VALUETYPE * row_descript = descript + idx * ndescrpt;
VALUETYPE * row_descript_deriv = descript_deriv + idx * descript_deriv_size;
VALUETYPE * row_rij = rij + idx * rij_size;
FPTYPE * row_descript = descript + idx * ndescrpt;
FPTYPE * row_descript_deriv = descript_deriv + idx * descript_deriv_size;
FPTYPE * row_rij = rij + idx * rij_size;
int * row_nlist = nlist + idx * nlist_size;

if (row_nlist[idy] >= 0) {
const int & j_idx = row_nlist[idy];
for (int kk = 0; kk < 3; kk++) {
row_rij[idy * 3 + kk] = coord[j_idx * 3 + kk] - coord[idx * 3 + kk];
}
const compute_t * rr = &row_rij[idy * 3 + 0];
compute_t nr2 = dev_dot(rr, rr);
compute_t inr = 1./sqrt(nr2);
compute_t nr = nr2 * inr;
compute_t inr2 = inr * inr;
compute_t inr4 = inr2 * inr2;
compute_t inr3 = inr4 * nr;
compute_t sw, dsw;
const FPTYPE * rr = &row_rij[idy * 3 + 0];
FPTYPE nr2 = dev_dot(rr, rr);
FPTYPE inr = 1./sqrt(nr2);
FPTYPE nr = nr2 * inr;
FPTYPE inr2 = inr * inr;
FPTYPE inr4 = inr2 * inr2;
FPTYPE inr3 = inr4 * nr;
FPTYPE sw, dsw;
spline5_switch(sw, dsw, nr, rmin, rmax);
row_descript[idx_value + 0] = (1./nr) ;//* sw;
row_descript[idx_value + 1] = (rr[0] / nr2) ;//* sw;
Expand Down
32 changes: 32 additions & 0 deletions source/tests/test_compat_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os,sys
import numpy as np
import unittest

from deepmd.compat import convert_input_v0_v1
from deepmd.common import j_loader

class TestConvertInput (unittest.TestCase) :
def test_convert_smth(self):
jdata0 = j_loader(os.path.join('compat_inputs', 'water_se_a_v0.json'))
jdata1 = j_loader(os.path.join('compat_inputs', 'water_se_a_v1.json'))
jdata = convert_input_v0_v1(jdata0, warning = False, dump = None)
self.assertEqual(jdata, jdata1)

def test_convert_nonsmth(self):
jdata0 = j_loader(os.path.join('compat_inputs', 'water_v0.json'))
jdata1 = j_loader(os.path.join('compat_inputs', 'water_v1.json'))
jdata = convert_input_v0_v1(jdata0, warning = False, dump = None)
self.assertEqual(jdata, jdata1)

def test_json_yaml_equal(self):

inputs = ("water_v1", "water_se_a_v1")

for i in inputs:
jdata = j_loader(os.path.join('yaml_inputs', f'{i}.json'))
ydata = j_loader(os.path.join('yaml_inputs', f'{i}.yaml'))
self.assertEqual(jdata, ydata)

with self.assertRaises(TypeError):
j_loader("path_with_wrong.extension")

23 changes: 0 additions & 23 deletions source/tests/test_compat_input_v0_v1.py

This file was deleted.

7 changes: 3 additions & 4 deletions source/tests/test_data_modifier.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os,sys,platform,json
import os,sys,platform
import numpy as np
import unittest
from deepmd.env import tf

from deepmd.common import j_must_have, data_requirement
from deepmd.common import j_must_have, data_requirement, j_loader
from deepmd.RunOptions import RunOptions
from deepmd.Trainer import NNPTrainer
from deepmd.DataSystem import DeepmdDataSystem
Expand Down Expand Up @@ -45,8 +45,7 @@ def tearDown(self):
def _setUp(self):
args = Args()
run_opt = RunOptions(args, False)
with open (args.INPUT, 'r') as fp:
jdata = json.load (fp)
jdata = j_loader(args.INPUT)

# init model
model = NNPTrainer (jdata, run_opt = run_opt)
Expand Down
8 changes: 4 additions & 4 deletions source/tests/test_fitting_stat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os,sys,json
import os,sys
import numpy as np
import unittest

from collections import defaultdict
from deepmd.DescrptSeA import DescrptSeA
from deepmd.Fitting import EnerFitting
from deepmd.common import j_loader

input_json = 'water_se_a_afparam.json'

Expand Down Expand Up @@ -57,9 +58,8 @@ def _brute_aparam(data, ndim):

class TestEnerFittingStat (unittest.TestCase) :
def test (self) :
with open(input_json) as fp:
jdata = json.load(fp)
jdata = jdata['model']
jdata = j_loader(input_json)
jdata = jdata['model']
descrpt = DescrptSeA(jdata['descriptor'])
fitting = EnerFitting(jdata['fitting_net'], descrpt)
avgs = [0, 10]
Expand Down
7 changes: 3 additions & 4 deletions source/tests/test_model_loc_frame.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dpdata,os,sys,json,unittest
import dpdata,os,sys,unittest
import numpy as np
from deepmd.env import tf
from common import Data,gen_data
Expand All @@ -8,7 +8,7 @@
from deepmd.DescrptLocFrame import DescrptLocFrame
from deepmd.Fitting import EnerFitting
from deepmd.Model import Model
from deepmd.common import j_must_have, j_must_have_d, j_have
from deepmd.common import j_must_have, j_must_have_d, j_have, j_loader

global_ener_float_precision = tf.float64
global_tf_float_precision = tf.float64
Expand All @@ -21,8 +21,7 @@ def setUp(self) :

def test_model(self):
jfile = 'water.json'
with open(jfile) as fp:
jdata = json.load (fp)
jdata = j_loader(jfile)
run_opt = RunOptions(None)
systems = j_must_have(jdata, 'systems')
set_pfx = j_must_have(jdata, 'set_prefix')
Expand Down
8 changes: 4 additions & 4 deletions source/tests/test_model_se_a.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dpdata,os,sys,json,unittest
import dpdata,os,sys,unittest
import numpy as np
from deepmd.env import tf
from common import Data,gen_data
Expand All @@ -9,7 +9,7 @@
from deepmd.DescrptSeA import DescrptSeA
from deepmd.Fitting import EnerFitting
from deepmd.Model import Model
from deepmd.common import j_must_have, j_must_have_d, j_have
from deepmd.common import j_must_have, j_must_have_d, j_have, j_loader

global_ener_float_precision = tf.float64
global_tf_float_precision = tf.float64
Expand All @@ -21,8 +21,8 @@ def setUp(self) :

def test_model(self):
jfile = 'water_se_a.json'
with open(jfile) as fp:
jdata = json.load (fp)
jdata = j_loader(jfile)

run_opt = RunOptions(None)
systems = j_must_have(jdata, 'systems')
set_pfx = j_must_have(jdata, 'set_prefix')
Expand Down
Loading