[轉載] 安裝 DeepMD-kit v1.0
原作者:曾晉哲
原連結:
https://mp.weixin.qq.com/s/DeQZKwoyxXK7rHhhmdgTmw
https://mp.weixin.qq.com/s/MsEtgnN_mi-auiFyXYUquA
假定已經安裝了Anaconda(建議使用最新版2019.07),已連線網際網路,則
1.安裝tensorflow(如僅需CPU版本的TensorFlow,則將tensorflow-gpu改為tensorflow):
python -m pip install tensorflow
Successfully installed google-pasta-0.1.7 keras-applications-1.0.8 opt-einsum-3.1.0 tensorboard-2.0.0 tensorflow-estimator-2.0.0 tensorflow-gpu-2.0.0
2.安裝deepmd-kit v1.0:
python -m pip install git+https://github.com/deepmodeling/deepmd-kit
Building wheels for collected packages: deepmd-kit
Building wheel for deepmd-kit (PEP 517) … done
Created wheel for deepmd-kit: filename=deepmd_kit-1.0.0-cp37-cp37m-linux_x86_64.whl size=268836 sha256=1f5b1149bbf35c0c96c713cc8b607e0626ad0df6451a7
Stored in directory: /tmp/pip-ephem-wheel-cache-zlksq4dl/wheels/a2/80/6c/a26fba79e43199eb4cdba7a3686c5370d3620916f5a0ea23ac
Successfully built deepmd-kit
Installing collected packages: deepmd-kit
Successfully built deepmd-kit
Installing collected packages: deepmd-kit
Successfully installed deepmd-kit-1.0.0
大功告成!現在看一看是否成功安裝:
dp -h
usage: dp [-h] {train,freeze,test} …
DeePMD-kit: A deep learning package for many-body potential energy
representation and molecular dynamics
optional arguments:
-h, –help show this help message and exit
Valid subcommands:
{train,freeze,test}
train train a model
freeze freeze the model
test test the model
現在,DeePMD-kit v1.0.0已成功安裝。下一期將介紹如何用DP編譯LAMMPS
TensorFlow 安裝
最新版本的 TensorFlow 要求 GLIBC 2.17 以上,儘管推薦做法是找一臺最新系統的機子,但是有時候系統的型別不是由自己決定的,通常又沒有root許可權,又想在所有機子上都能執行 TensorFlow 。
剛好手裡有一個超算賬號,系統是 Red Hat 4.4.7 ,GLIBC 版本是 2.12 ,就以此為例,安裝CPU版本的TensorFlow(反正沒有許可權也安裝不了GPU版本需要的驅動)。
一、用 Anaconda 3 安裝 TensorFlow 1.8
1.安裝 Anaconda 3
2.建立 TensorFlow 環境
conda create -n tensorflow pip python=3.6
#Proceed ([y]/n)? 輸y
source activate tensorflow #啟用環境
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/
#這兩天由於眾所周知的原因,Google官方的映象又下載不了了,所以這裡用了清華大學的映象
二、安裝 gcc
這時候開啟 Python ,執行 import tensorflow ,提示:
ImportError: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.7′ not found
conda install -c psi4 gcc-5
#Proceed ([y]/n)? 輸y
LD_LIBRARY_PATH=$HOME/anaconda3/envs/tensorflow/lib:$LD_LIBRARY_PATH
再此執行 Python,不再提示這個問題。
三、安裝 GLIBC 2.21
但是提示:
ImportError: /lib64/libc.so.6: version `GLIBC_2.16′ not found
本來應該安裝GLIBC 2.17,但是我發現從2.16到2.19都有個bug,不能執行Python 3.6。於是我們安裝GLIBC 2.21。
1.下載GLIBC 2.21並編譯GLIBC 2.21
wget http://mirror.rit.edu/gnu/libc/glibc-2.21.tar.gz
tar zxvf glibc-2.21.tar.gz
mkdir glibc-2.21-build glibc-2.21-install
cd glibc-2.21-build
../glibc-2.21/configure --prefix=`readlink -f ../glibc-2.21-install`
make && make install
然後就報錯了:
checking version of as… 2.20.51.0.2, bad
checking version of ld… 2.20.51.0.2, bad
These critical programs are missing or too old: as ld
仔細看看INSTALL檔案,要求GNU ‘binutils’ 2.22 or later,但系統只裝了2.20。
2.下載並編譯binutils 2.30
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.30.tar.gz
tar zxvf binutils-2.30.tar.gz
cd binutils-2.30
./configure --prefix=`readlink -f ../binutils-2.30-install`
make && make install
#加入環境變數
PATH=$HOME/software/binutils-2.30-install/bin:$PATH
3.重新編譯glibc 2.21
cd glibc-2.21-build
../glibc-2.21/configure --prefix=`readlink -f ../glibc-2.21-install`
make && make install
Warning: ignoring configuration file that cannot be opened: … /software/glibc-2.21-install/etc/ld.so.conf: No such file or directory
將/etc 目錄的ld.so.conf複製到指定目錄後重新安裝:
cp /etc/ld.so.conf ../glibc-2.21-install/etc/
make install
安裝成功。
四、執行TensorFlow
source activate tensorflow
$HOME/software/glibc-2.21-install/lib/ld-2.21.so --library-path $HOME/anaconda3/envs/tensorflow/lib:$HOME/software/glibc-2.21-install/lib:/lib64:$LD_LIBRARY_PATH `which python`
在Python內輸入:
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
b’Hello, TensorFlow!’
執行成功。我們可以執行的命令記錄在.bashrc中:
echo 'alias tf='"'"'$HOME/software/glibc-2.21-install/lib/ld-2.21.so --library-path $HOME/anaconda3/envs/tensorflow/lib:$HOME/software/glib-2.21-install/lib:/lib64:$LD_LIBRARY_PATH `which python`'"'">>$HOME/.bashrcsource $HOME/.bashrc
即可用 tf 代替裝了 TensorFlow 的 Python。
升級glibc2.23時編譯錯誤
https://blog.csdn.net/gx1313113/article/details/101154742