Skip to content

Commit 6b9c29e

Browse files
author
Han Wang
committed
merge with devel
2 parents 6475295 + d737df0 commit 6b9c29e

File tree

180 files changed

+12030
-2700
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+12030
-2700
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
*.gz
1313
*.bz2
1414
*.pyc
15+
tmp*
1516
CMakeCache.txt
1617
CMakeFiles
18+
*.bk
19+
build
20+
_skbuild
21+
deepmd_kit.egg-info/
22+
dist
23+
.eggs
24+
_version.py
25+
venv*

.travis.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
language: python
2+
addons:
3+
apt:
4+
sources:
5+
- ubuntu-toolchain-r-test
6+
packages:
7+
- gcc-4.8
8+
- g++-4.8
9+
- gcc-5
10+
- g++-5
11+
- gcc-6
12+
- g++-6
13+
- gcc-7
14+
- g++-7
15+
- gcc-8
16+
- g++-8
17+
matrix:
18+
include:
19+
- python: 3.6
20+
env:
21+
- CC=gcc-4.8
22+
- CXX=g++-4.8
23+
- TENSORFLOW_VERSION=1.8
24+
- python: 3.6
25+
env:
26+
- CC=gcc-4.8
27+
- CXX=g++-4.8
28+
- TENSORFLOW_VERSION=1.12
29+
- python: 3.6
30+
env:
31+
- CC=gcc-4.8
32+
- CXX=g++-4.8
33+
- TENSORFLOW_VERSION=1.14
34+
- python: 3.7
35+
env:
36+
- CC=gcc-5
37+
- CXX=g++-5
38+
- TENSORFLOW_VERSION=1.14
39+
- python: 3.7
40+
env:
41+
- CC=gcc-6
42+
- CXX=g++-6
43+
- TENSORFLOW_VERSION=1.14
44+
- python: 3.7
45+
env:
46+
- CC=gcc-7
47+
- CXX=g++-7
48+
- TENSORFLOW_VERSION=1.14
49+
- python: 3.7
50+
env:
51+
- CC=gcc-8
52+
- CXX=g++-8
53+
- TENSORFLOW_VERSION=1.14
54+
- python: 3.7
55+
env:
56+
- CC=gcc-5
57+
- CXX=g++-5
58+
- TENSORFLOW_VERSION=2.0
59+
- python: 3.7
60+
env:
61+
- CC=gcc-8
62+
- CXX=g++-8
63+
- TENSORFLOW_VERSION=2.0
64+
before_install:
65+
- pip install --upgrade pip
66+
- pip install --upgrade setuptools
67+
- pip install tensorflow==$TENSORFLOW_VERSION
68+
install:
69+
- pip install --verbose .[test]
70+
script:
71+
- cd source/tests && python -m unittest

README.md

Lines changed: 237 additions & 219 deletions
Large diffs are not rendered by default.

data/raw/raw_to_set.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test -f energy.raw && split energy.raw -l $nline_per_set -d -a 3 energy.raw
1616
test -f force.raw && split force.raw -l $nline_per_set -d -a 3 force.raw
1717
test -f virial.raw && split virial.raw -l $nline_per_set -d -a 3 virial.raw
1818
test -f atom_ener.raw && split atom_ener.raw -l $nline_per_set -d -a 3 atom_ener.raw
19+
test -f fparam.raw && split fparam.raw -l $nline_per_set -d -a 3 fparam.raw
1920

2021
nset=`ls | grep box.raw[0-9] | wc -l`
2122
nset_1=$(($nset-1))
@@ -32,6 +33,7 @@ do
3233
test -f force.raw$pi && mv force.raw$pi set.$pi/force.raw
3334
test -f virial.raw$pi && mv virial.raw$pi set.$pi/virial.raw
3435
test -f atom_ener.raw$pi && mv atom_ener.raw$pi set.$pi/atom_ener.raw
36+
test -f fparam.raw$pi && mv fparam.raw$pi set.$pi/fparam.raw
3537

3638
cd set.$pi
3739
python -c 'import numpy as np; data = np.loadtxt("box.raw" ); data = data.astype (np.float32); np.save ("box", data)'
@@ -63,6 +65,13 @@ if os.path.isfile("atom_ener.raw"):
6365
data = np.loadtxt("atom_ener.raw");
6466
data = data.astype (np.float32);
6567
np.save ("atom_ener", data)
68+
'
69+
python -c \
70+
'import numpy as np; import os.path;
71+
if os.path.isfile("fparam.raw"):
72+
data = np.loadtxt("fparam.raw");
73+
data = data.astype (np.float32);
74+
np.save ("fparam", data)
6675
'
6776
rm *.raw
6877
cd ../

deepmd/__about__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = 'unknown'

deepmd/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from .env import set_mkl
2+
from .DeepEval import DeepEval
3+
from .DeepPot import DeepPot
4+
from .DeepPolar import DeepPolar
5+
from .DeepWFC import DeepWFC
6+
7+
set_mkl()
8+
9+
try:
10+
from ._version import version as __version__
11+
except ImportError:
12+
from .__about__ import __version__
13+

deepmd/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .main import main
2+
3+
if __name__ == '__main__':
4+
main()
5+

doc/install-tf.1.12.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
# Install tensorflow's Python interface
2-
We follow the virtual environment approach to install the tensorflow's Python interface. The full instruction can be found on [the tensorflow's official website](https://www.tensorflow.org/install/pip). Now we assume that the Python interface will be installed to virtual environment directory `$tensorflow_venv`
3-
```bash
4-
virtualenv --system-site-packages -p python3 $tensorflow_venv
5-
source $tensorflow_venv/bin/activate
6-
pip install --upgrade pip
7-
pip install --upgrade tensorflow==1.12.0
8-
```
9-
To verify the installation,
10-
```bash
11-
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
12-
```
13-
14-
One should remember to activate the virtual environment every time he/she runs deepmd training program `dp_train`.
15-
161
# Install tensorflow's C++ interface
172
The tensorflow's C++ interface will be compiled from the source code. Firstly one installs bazel. It is highly recommended that the bazel version 0.15.0 is used. A full instruction of bazel installation can be found [here](https://docs.bazel.build/versions/master/install.html).
183
```bash

doc/install-tf.1.14-gpu.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Install tensorflow-gpu's C++ interface
2+
The tensorflow's C++ interface will be compiled from the source code. Firstly one installs bazel. It is highly recommended that the bazel version 0.24.1 is used. A full instruction of bazel installation can be found [here](https://docs.bazel.build/versions/master/install.html).
3+
```bash
4+
cd /some/workspace
5+
wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-dist.zip
6+
mkdir bazel-0.24.1
7+
cd bazel-0.24.1
8+
unzip ../bazel-0.24.1-dist.zip
9+
./compile.sh
10+
export PATH=`pwd`/output:$PATH
11+
```
12+
13+
Firstly get the source code of the tensorflow
14+
```bash
15+
cd /some/workspace
16+
git clone https://github.com/tensorflow/tensorflow tensorflow -b v1.14.0 --depth=1
17+
cd tensorflow
18+
```
19+
20+
DeePMD-kit is compiled by cmake, so we need to compile and integrate tensorflow with cmake projects. The rest of this section basically follows [the instruction provided by Tuatini](http://tuatini.me/building-tensorflow-as-a-standalone-project/). Now execute
21+
22+
You will answer a list of questions that help configure the building of tensorflow. It is recommended to build for Python3. You may want to answer the question like this (please replace `$tensorflow_venv` by the virtual environment directory):
23+
```bash
24+
./configure
25+
Please specify the location of python. [Default is xxx]:
26+
27+
Traceback (most recent call last):
28+
File "<string>", line 1, in <module>
29+
AttributeError: module 'site' has no attribute 'getsitepackages'
30+
Found possible Python library paths:
31+
/xxx/deepmd_gpu/tensorflow_venv/lib/python3.7/site-packages
32+
Please input the desired Python library path to use. Default is [xxx]
33+
34+
Do you wish to build TensorFlow with XLA JIT support? [Y/n]:
35+
XLA JIT support will be enabled for TensorFlow.
36+
37+
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]:
38+
No OpenCL SYCL support will be enabled for TensorFlow.
39+
40+
Do you wish to build TensorFlow with ROCm support? [y/N]:
41+
No ROCm support will be enabled for TensorFlow.
42+
43+
Do you wish to build TensorFlow with CUDA support? [y/N]: y
44+
CUDA support will be enabled for TensorFlow.
45+
46+
Do you wish to build TensorFlow with TensorRT support? [y/N]:
47+
No TensorRT support will be enabled for TensorFlow.
48+
49+
Found CUDA 10.1 in:
50+
/usr/local/cuda/lib64
51+
/usr/local/cuda/include
52+
Found cuDNN 7 in:
53+
/usr/local/cuda/lib64
54+
/usr/local/cuda/include
55+
56+
Please specify a list of comma-separated CUDA compute capabilities you want to build with.
57+
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
58+
Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 6.1,6.1]:
59+
60+
Do you want to use clang as CUDA compiler? [y/N]:
61+
nvcc will be used as CUDA compiler.
62+
63+
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
64+
65+
66+
Do you wish to build TensorFlow with MPI support? [y/N]:
67+
No MPI support will be enabled for TensorFlow.
68+
69+
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]:
70+
71+
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:
72+
Not configuring the WORKSPACE for Android builds.
73+
74+
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
75+
--config=mkl # Build with MKL support.
76+
--config=monolithic # Config for mostly static monolithic build.
77+
--config=gdr # Build with GDR support.
78+
--config=verbs # Build with libverbs support.
79+
--config=ngraph # Build with Intel nGraph support.
80+
--config=numa # Build with NUMA support.
81+
--config=dynamic_kernels # (Experimental) Build kernels into separate shared objects.
82+
--config=v2 # Build TensorFlow 2.x instead of 1.x.
83+
Preconfigured Bazel build configs to DISABLE default on features:
84+
--config=noaws # Disable AWS S3 filesystem support.
85+
--config=nogcp # Disable GCP support.
86+
--config=nohdfs # Disable HDFS support.
87+
--config=noignite # Disable Apache Ignite support.
88+
--config=nokafka # Disable Apache Kafka support.
89+
--config=nonccl # Disable NVIDIA NCCL support.
90+
Configuration finished
91+
```
92+
93+
The library path for Python should be set accordingly.
94+
95+
Now build the shared library of tensorflow:
96+
```bash
97+
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
98+
```
99+
You may want to add options `--copt=-msse4.2`, `--copt=-mavx`, `--copt=-mavx2` and `--copt=-mfma` to enable SSE4.2, AVX, AVX2 and FMA SIMD accelerations, respectively. It is noted that these options should be chosen according to the CPU architecture. If the RAM becomes an issue of your machine, you may limit the RAM usage by using `--local_resources 2048,.5,1.0`.
100+
101+
Now I assume you want to install tensorflow in directory `$tensorflow_root`. Create the directory if it does not exists
102+
```bash
103+
mkdir -p $tensorflow_root
104+
```
105+
Now, copy the libraries to the tensorflow's installation directory:
106+
```bash
107+
mkdir $tensorflow_root/lib
108+
cp -d bazel-bin/tensorflow/libtensorflow_cc.so* $tensorflow_root/lib/
109+
cp -d bazel-bin/tensorflow/libtensorflow_framework.so* $tensorflow_root/lib/
110+
cp -d $tensorflow_root/lib/libtensorflow_framework.so.1 $tensorflow_root/lib/libtensorflow_framework.so
111+
```
112+
Then copy the headers
113+
```bash
114+
mkdir -p $tensorflow_root/include/tensorflow
115+
cp -r bazel-genfiles/* $tensorflow_root/include/
116+
cp -r tensorflow/cc $tensorflow_root/include/tensorflow
117+
cp -r tensorflow/core $tensorflow_root/include/tensorflow
118+
cp -r third_party $tensorflow_root/include
119+
cp -r bazel-tensorflow/external/eigen_archive/Eigen/ $tensorflow_root/include
120+
cp -r bazel-tensorflow/external/eigen_archive/unsupported/ $tensorflow_root/include
121+
rsync -avzh --include '*/' --include '*.h' --include '*.inc' --exclude '*' bazel-tensorflow/external/protobuf_archive/src/ $tensorflow_root/include/
122+
rsync -avzh --include '*/' --include '*.h' --include '*.inc' --exclude '*' bazel-tensorflow/external/com_google_absl/absl/ $tensorflow_root/include/absl
123+
```
124+
Now clean up the source files in the header directories:
125+
```bash
126+
cd $tensorflow_root/include
127+
find . -name "*.cc" -type f -delete
128+
```
129+
130+
# Troubleshooting
131+
```bash
132+
git: unknown command -C ...
133+
```
134+
This may be your git version issue, because low version of git does not support this command. Upgrading your git maybe helpful.
135+
136+
```bash
137+
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
138+
Please set them or make sure they are set and tested correctly in the CMake files:
139+
FFTW_LIB (ADVANCED)
140+
linked by target "FFTW" in directory xxx
141+
```
142+
Currently, when building eigen package, you can delete the FFTW in the cmake file.
143+
144+
```bash
145+
fatal error: absl/numeric/int128_have_intrinsic.inc: No such file or directory
146+
```
147+
Basicly, you could build an empty file named "int128_have_intrinsic.inc" at the same directory of "int128.h".
148+
149+

doc/install-tf.1.14.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Install tensorflow's C++ interface
2+
The tensorflow's C++ interface will be compiled from the source code. Firstly one installs bazel. It is highly recommended that the bazel version 0.24.1 is used. A full instruction of bazel installation can be found [here](https://docs.bazel.build/versions/master/install.html).
3+
```bash
4+
cd /some/workspace
5+
wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-dist.zip
6+
mkdir bazel-0.24.1
7+
cd bazel-0.24.1
8+
unzip ../bazel-0.24.1-dist.zip
9+
./compile.sh
10+
export PATH=`pwd`/output:$PATH
11+
```
12+
13+
Firstly get the source code of the tensorflow
14+
```bash
15+
cd /some/workspace
16+
git clone https://github.com/tensorflow/tensorflow tensorflow -b v1.14.0 --depth=1
17+
cd tensorflow
18+
```
19+
20+
DeePMD-kit is compiled by cmake, so we need to compile and integrate tensorflow with cmake projects. The rest of this section basically follows [the instruction provided by Tuatini](http://tuatini.me/building-tensorflow-as-a-standalone-project/). Now execute
21+
```bash
22+
./configure
23+
```
24+
You will answer a list of questions that help configure the building of tensorflow. It is recommended to build for Python3. You may want to answer the question like this (please replace `$tensorflow_venv` by the virtual environment directory):
25+
```bash
26+
Please specify the location of python. [Default is $tensorflow_venv/bin/python]:
27+
```
28+
The library path for Python should be set accordingly.
29+
30+
Now build the shared library of tensorflow:
31+
```bash
32+
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
33+
```
34+
You may want to add options `--copt=-msse4.2`, `--copt=-mavx`, `--copt=-mavx2` and `--copt=-mfma` to enable SSE4.2, AVX, AVX2 and FMA SIMD accelerations, respectively. It is noted that these options should be chosen according to the CPU architecture. If the RAM becomes an issue of your machine, you may limit the RAM usage by using `--local_resources 2048,.5,1.0`.
35+
36+
Now I assume you want to install tensorflow in directory `$tensorflow_root`. Create the directory if it does not exists
37+
```bash
38+
mkdir -p $tensorflow_root
39+
```
40+
Now, copy the libraries to the tensorflow's installation directory:
41+
```bash
42+
mkdir $tensorflow_root/lib
43+
cp -d bazel-bin/tensorflow/libtensorflow_cc.so* $tensorflow_root/lib/
44+
cp -d bazel-bin/tensorflow/libtensorflow_framework.so* $tensorflow_root/lib/
45+
```
46+
Then copy the headers
47+
```bash
48+
mkdir -p $tensorflow_root/include/tensorflow
49+
cp -r bazel-genfiles/* $tensorflow_root/include/
50+
cp -r tensorflow/cc $tensorflow_root/include/tensorflow
51+
cp -r tensorflow/core $tensorflow_root/include/tensorflow
52+
cp -r third_party $tensorflow_root/include
53+
cp -r bazel-tensorflow/external/eigen_archive/Eigen/ $tensorflow_root/include
54+
cp -r bazel-tensorflow/external/eigen_archive/unsupported/ $tensorflow_root/include
55+
rsync -avzh --include '*/' --include '*.h' --include '*.inc' --exclude '*' bazel-tensorflow/external/protobuf_archive/src/ $tensorflow_root/include/
56+
rsync -avzh --include '*/' --include '*.h' --include '*.inc' --exclude '*' bazel-tensorflow/external/com_google_absl/absl/ $tensorflow_root/include/absl
57+
```
58+
Now clean up the source files in the header directories:
59+
```bash
60+
cd $tensorflow_root/include
61+
find . -name "*.cc" -type f -delete
62+
```

0 commit comments

Comments
 (0)