Skip to content

Commit c62289f

Browse files
author
Han Wang
committed
update installation instruction
1 parent b688b6b commit c62289f

File tree

3 files changed

+238
-114
lines changed

3 files changed

+238
-114
lines changed

README.md

Lines changed: 3 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
- [Download and install](#download-and-install)
1212
- [Easy installation methods](#easy-installation-methods)
1313
- [Install DeePMD-kit from scratch](#install-deepmd-kit-from-scratch)
14-
- [Install tensorflow's Python interface](#install-tensorflows-python-interface)
15-
- [Install tensorflow's C++ interface](#install-tensorflows-c-interface)
16-
- [Install xdrfile](#install-xdrfile)
14+
- [Install tensorflow](#install-tensorflow)
1715
- [Install DeePMD-kit](#install-deepmd-kit)
1816
- [Install LAMMPS's DeePMD-kit module](#install-lammpss-deepmd-kit-module)
1917
- [Build DeePMD-kit with GPU support](#build-deepmd-kit-with-gpu-support)
@@ -88,117 +86,8 @@ A docker for installing the DeePMD-kit on CentOS 7 is available [here](https://g
8886
## Install DeePMD-kit from scratch
8987
Installing DeePMD-kit from scratch is lengthy, but do not be panic. Just follow step by step. Wish you good luck..
9088

91-
### Install tensorflow's Python interface
92-
There are two ways of installing the Python interface of tensorflow, either [using google's binary](https://www.tensorflow.org/install/install_linux), or [installing from sources](https://www.tensorflow.org/install/install_sources). When you are using google's binary, do not forget to add the option `-DTF_GOOGLE_BIN=true` when building DeePMD-kit.
93-
94-
### Install tensorflow's C++ interface
95-
The tensorflow's C++ interface will be compiled from the source code. Before starting compilation, it may be a good idea to check the environment requirement of tensorflow by the [officially tested configurations](https://www.tensorflow.org/install/install_sources#tested_source_configurations). If you do not have `bazel`, please [install it](https://docs.bazel.build/versions/master/install.html).
96-
97-
Firstly get the source code of the tensorflow
98-
```bash
99-
cd /some/workspace
100-
git clone https://github.com/tensorflow/tensorflow tensorflow
101-
```
102-
The DeePMD-kit works with tensorflow r1.4 and later versions. Now taking r1.8 for example:
103-
```bash
104-
cd tensorflow
105-
git checkout r1.8
106-
```
107-
108-
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
109-
```bash
110-
./configure
111-
```
112-
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:
113-
```bash
114-
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3
115-
```
116-
The library path for Python should be set accordingly.
117-
118-
Now build the shared library of tensorflow:
119-
```bash
120-
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
121-
```
122-
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`.
123-
124-
Now I assume you want to install tensorflow in directory `$tensorflow_root`. Create the directory if it does not exists
125-
```bash
126-
mkdir -p $tensorflow_root
127-
```
128-
Before moving on, we need to compile the dependencies of tensorflow, including Protobuf, Eigen and nsync. Firstly, protobuf
129-
```bash
130-
mkdir /tmp/proto
131-
tensorflow/contrib/makefile/download_dependencies.sh
132-
cd tensorflow/contrib/makefile/downloads/protobuf/
133-
./autogen.sh
134-
./configure --prefix=/tmp/proto/
135-
make
136-
make install
137-
```
138-
Then Eigen
139-
```bash
140-
mkdir /tmp/eigen
141-
cd ../eigen
142-
mkdir build_dir
143-
cd build_dir
144-
cmake -DCMAKE_INSTALL_PREFIX=/tmp/eigen/ ../
145-
make install
146-
```
147-
And nsync
148-
```bash
149-
mkdir /tmp/nsync
150-
cd ../../nsync
151-
mkdir build_dir
152-
cd build_dir
153-
cmake -DCMAKE_INSTALL_PREFIX=/tmp/nsync/ ../
154-
make
155-
make install
156-
cd ../../../../../..
157-
```
158-
Now, copy the libraries to the tensorflow's installation directory:
159-
```bash
160-
mkdir $tensorflow_root/lib
161-
cp bazel-bin/tensorflow/libtensorflow_cc.so $tensorflow_root/lib/
162-
cp bazel-bin/tensorflow/libtensorflow_framework.so $tensorflow_root/lib/
163-
cp /tmp/proto/lib/libprotobuf.a $tensorflow_root/lib/
164-
cp /tmp/nsync/lib/libnsync.a $tensorflow_root/lib/
165-
```
166-
Then copy the headers
167-
```bash
168-
mkdir -p $tensorflow_root/include/tensorflow
169-
cp -r bazel-genfiles/* $tensorflow_root/include/
170-
cp -r tensorflow/cc $tensorflow_root/include/tensorflow
171-
cp -r tensorflow/core $tensorflow_root/include/tensorflow
172-
cp -r third_party $tensorflow_root/include
173-
cp -r /tmp/proto/include/* $tensorflow_root/include
174-
cp -r /tmp/eigen/include/eigen3/* $tensorflow_root/include
175-
cp -r /tmp/nsync/include/*h $tensorflow_root/include
176-
```
177-
Now clean up the source files in the header directories:
178-
```bash
179-
cd $tensorflow_root/include
180-
find . -name "*.cc" -type f -delete
181-
```
182-
The temporary installation directories for the dependencies can be removed:
183-
```bash
184-
rm -fr /tmp/proto /tmp/eigen /tmp/nsync
185-
```
186-
187-
### Install xdrfile
188-
xdrfile is a lib that reads, compresses and writes the MD trajectories. Firstly get the source:
189-
```bash
190-
cd /some/workspace
191-
wget ftp://ftp.gromacs.org/pub/contrib/xdrfile-1.1.4.tar.gz
192-
```
193-
I assume you want to install it in `$xdrfile_root`, then you will probably do
194-
```bash
195-
tar xvf xdrfile-1.1.4.tar.gz
196-
cd xdrfile-1.1.4
197-
./configure --prefix=$xdrfile_root
198-
make
199-
make install
200-
```
201-
89+
### Install tensorflow
90+
We tested two tensorflow installation options. You may follow either [tf-1.8](doc/install-tf.1.8.md) or [tf-1.12](doc/install-tf.1.12.md). Click one of the links and follow the instructions therein. Of course, other installation options are not forbidden.
20291

20392
### Install DeePMD-kit
20493
The DeePMD-kit was tested with compiler gcc >= 4.9.

doc/install-tf.1.12.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
16+
# Install tensorflow's C++ interface
17+
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).
18+
```bash
19+
cd /some/workspace
20+
wget https://github.com/bazelbuild/bazel/releases/download/0.15.0/bazel-0.15.0-dist.zip
21+
mkdir bazel-0.15.0
22+
cd bazel-0.15.0
23+
unzip ../bazel-0.15.0-dist.zip
24+
./compile.sh
25+
export PATH=`pwd`/output:$PATH
26+
```
27+
28+
Firstly get the source code of the tensorflow
29+
```bash
30+
cd /some/workspace
31+
git clone https://github.com/tensorflow/tensorflow tensorflow
32+
cd tensorflow
33+
git checkout v1.12.0
34+
```
35+
36+
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
37+
```bash
38+
./configure
39+
```
40+
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):
41+
```bash
42+
Please specify the location of python. [Default is $tensorflow_venv/bin/python]:
43+
```
44+
The library path for Python should be set accordingly.
45+
46+
Now build the shared library of tensorflow:
47+
```bash
48+
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
49+
```
50+
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`.
51+
52+
Now I assume you want to install tensorflow in directory `$tensorflow_root`. Create the directory if it does not exists
53+
```bash
54+
mkdir -p $tensorflow_root
55+
```
56+
Before moving on, we need to compile the dependencies of tensorflow, including Protobuf, Eigen, nsync and absl. Firstly, protobuf
57+
```bash
58+
mkdir /tmp/proto
59+
sed -i 's;PROTOBUF_URL=.*;PROTOBUF_URL=\"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz\";g' tensorflow/contrib/makefile/download_dependencies.sh
60+
tensorflow/contrib/makefile/download_dependencies.sh
61+
cd tensorflow/contrib/makefile/downloads/protobuf/
62+
./autogen.sh
63+
./configure --prefix=/tmp/proto/
64+
make
65+
make install
66+
```
67+
Then Eigen
68+
```bash
69+
mkdir /tmp/eigen
70+
cd ../eigen
71+
mkdir build_dir
72+
cd build_dir
73+
cmake -DCMAKE_INSTALL_PREFIX=/tmp/eigen/ ../
74+
make install
75+
```
76+
nsync
77+
```bash
78+
mkdir /tmp/nsync
79+
cd ../../nsync
80+
mkdir build_dir
81+
cd build_dir
82+
cmake -DCMAKE_INSTALL_PREFIX=/tmp/nsync/ ../
83+
make
84+
make install
85+
```
86+
And absl
87+
```bash
88+
cd ../../absl
89+
bazel build
90+
mkdir -p $tensorflow_root/include/
91+
rsync -avzh --include '*/' --include '*.h' --exclude '*' absl $tensorflow_root/include/
92+
cd ../../../../..
93+
```
94+
Now, copy the libraries to the tensorflow's installation directory:
95+
```bash
96+
mkdir $tensorflow_root/lib
97+
cp bazel-bin/tensorflow/libtensorflow_cc.so $tensorflow_root/lib/
98+
cp bazel-bin/tensorflow/libtensorflow_framework.so $tensorflow_root/lib/
99+
cp /tmp/proto/lib/libprotobuf.a $tensorflow_root/lib/
100+
cp /tmp/nsync/lib64/libnsync.a $tensorflow_root/lib/
101+
```
102+
Then copy the headers
103+
```bash
104+
mkdir -p $tensorflow_root/include/tensorflow
105+
cp -r bazel-genfiles/* $tensorflow_root/include/
106+
cp -r tensorflow/cc $tensorflow_root/include/tensorflow
107+
cp -r tensorflow/core $tensorflow_root/include/tensorflow
108+
cp -r third_party $tensorflow_root/include
109+
cp -r /tmp/proto/include/* $tensorflow_root/include
110+
cp -r /tmp/eigen/include/eigen3/* $tensorflow_root/include
111+
cp -r /tmp/nsync/include/*h $tensorflow_root/include
112+
```
113+
Now clean up the source files in the header directories:
114+
```bash
115+
cd $tensorflow_root/include
116+
find . -name "*.cc" -type f -delete
117+
```
118+
The temporary installation directories for the dependencies can be removed:
119+
```bash
120+
rm -fr /tmp/proto /tmp/eigen /tmp/nsync
121+
```
122+

doc/install-tf.1.8.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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.8.0
8+
```
9+
To verify the installation,
10+
```bash
11+
python -c "import tensorflow as tf; sess=tf.Session(); print(sess.run(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+
16+
# Install tensorflow's C++ interface
17+
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.10.0 is used. A full instruction of bazel installation can be found [here](https://docs.bazel.build/versions/master/install.html).
18+
```bash
19+
cd /some/workspace
20+
wget https://github.com/bazelbuild/bazel/releases/download/0.10.0/bazel-0.10.0-dist.zip
21+
mkdir bazel-0.10.0
22+
cd bazel-0.10.0
23+
unzip ../bazel-0.10.0-dist.zip
24+
./compile.sh
25+
export PATH=`pwd`/output:$PATH
26+
```
27+
28+
Firstly get the source code of the tensorflow
29+
```bash
30+
cd /some/workspace
31+
git clone https://github.com/tensorflow/tensorflow tensorflow
32+
cd tensorflow
33+
git checkout v1.8.0
34+
```
35+
36+
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
37+
```bash
38+
./configure
39+
```
40+
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):
41+
```bash
42+
Please specify the location of python. [Default is $tensorflow_venv/bin/python]:
43+
```
44+
The library path for Python should be set accordingly.
45+
46+
Now build the shared library of tensorflow:
47+
```bash
48+
bazel build -c opt --verbose_failures //tensorflow:libtensorflow_cc.so
49+
```
50+
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`.
51+
52+
Now I assume you want to install tensorflow in directory `$tensorflow_root`. Create the directory if it does not exists
53+
```bash
54+
mkdir -p $tensorflow_root
55+
```
56+
Before moving on, we need to compile the dependencies of tensorflow, including Protobuf, Eigen and nsync. Firstly, protobuf
57+
```bash
58+
mkdir /tmp/proto
59+
tensorflow/contrib/makefile/download_dependencies.sh
60+
cd tensorflow/contrib/makefile/downloads/protobuf/
61+
./autogen.sh
62+
./configure --prefix=/tmp/proto/
63+
make
64+
make install
65+
```
66+
Then Eigen
67+
```bash
68+
mkdir /tmp/eigen
69+
cd ../eigen
70+
mkdir build_dir
71+
cd build_dir
72+
cmake -DCMAKE_INSTALL_PREFIX=/tmp/eigen/ ../
73+
make install
74+
```
75+
And nsync
76+
```bash
77+
mkdir /tmp/nsync
78+
cd ../../nsync
79+
mkdir build_dir
80+
cd build_dir
81+
cmake -DCMAKE_INSTALL_PREFIX=/tmp/nsync/ ../
82+
make
83+
make install
84+
cd ../../../../../..
85+
```
86+
Now, copy the libraries to the tensorflow's installation directory:
87+
```bash
88+
mkdir $tensorflow_root/lib
89+
cp bazel-bin/tensorflow/libtensorflow_cc.so $tensorflow_root/lib/
90+
cp bazel-bin/tensorflow/libtensorflow_framework.so $tensorflow_root/lib/
91+
cp /tmp/proto/lib/libprotobuf.a $tensorflow_root/lib/
92+
cp /tmp/nsync/lib/libnsync.a $tensorflow_root/lib/
93+
```
94+
Then copy the headers
95+
```bash
96+
mkdir -p $tensorflow_root/include/tensorflow
97+
cp -r bazel-genfiles/* $tensorflow_root/include/
98+
cp -r tensorflow/cc $tensorflow_root/include/tensorflow
99+
cp -r tensorflow/core $tensorflow_root/include/tensorflow
100+
cp -r third_party $tensorflow_root/include
101+
cp -r /tmp/proto/include/* $tensorflow_root/include
102+
cp -r /tmp/eigen/include/eigen3/* $tensorflow_root/include
103+
cp -r /tmp/nsync/include/*h $tensorflow_root/include
104+
```
105+
Now clean up the source files in the header directories:
106+
```bash
107+
cd $tensorflow_root/include
108+
find . -name "*.cc" -type f -delete
109+
```
110+
The temporary installation directories for the dependencies can be removed:
111+
```bash
112+
rm -fr /tmp/proto /tmp/eigen /tmp/nsync
113+
```

0 commit comments

Comments
 (0)