docker下使用centos6.6 安裝vasp5.4步驟

myskies發表於2018-05-10

由於Intel編譯器支援的伺服器系統列表為:

Supported operating systems for this
release include:
    - Red Hat Enterprise Linux* 4.0, 5.0, 6.0 (IA-32/Intel(R) 64)
    - Fedora* 15 (IA-32/Intel(R) 64)
    - SuSE Linux* Enterprise Server* 10.x, 11.0 SP1(IA-32/Intel(R)64)
    - Asianux* Server 3.0, 4.0 (IA-32/Intel(R) 64)
    - Ubuntu* 10.04 LTS, 11.04 (IA-32/Intel(R) 64)
    - Debian 6.0 (IA-32/Intel(R) 64)

只有centos(Red Hat Enterprise Linux)6.6是存在官方的docker映象,所以,我們在這裡使用centos6.6進行安裝

[注意]

  • 伺服器記憶體不能少於2G,否則將會編譯錯誤
  • 在安裝過程中,系統不能重啟。否則部分環境變數將失效。

使用docker安裝centos6.6

啟動
#sudo docker build centos:6.6 ./
#sudo docker run -d --name {contanername} -v localpath:remotepath -t centos:6.6 `/bin/bash`
#sudo docker ps
#sudo docker exec -i -t containername `/bin/bash`

[注意]

  • {contanername} 換成你想起的容器名,比如vasp
  • localpath 本地路徑
  • remotepath docker虛擬機器的路徑

比如我使用以下命令安裝:
#sudo docker run -d --name vasp2 -v /home/panjie/:/home/panjie -t centos:6.6 `/bin/bash`

安裝擴充套件包

vasp需要一些擴充套件包列表為gcc,which,glibc(32w位),libstdc++(32位):
yum install -y rsync gcc-c++ which glibc-static.i686 libstdc++.i686
上面的擴充套件必須安裝,不然則會出現如下錯誤:

32-bit libraries not found on this system.

安裝JRE1.6

官方對jre是這麼說明的:

Finally, there is an optional package to consider: The 11.x version of the Intel Compiler for Linux has a graphical debugger, a new graphical interface for the IDB debugger. If you want to use this debugger, please make sure to install the JAVA JRE version 1.5 or higher.

也就是說,你要不安裝的話,可能會有BUG
#yum install java-1.6.0-openjdk

安裝編譯器

編譯器即把C語言的檔案變成可執行檔案的。編譯器有很多,支援的功能也不一樣。在編譯、連結VASP時,推薦使用INTEL的編譯器。這是由於VASP軟體使用了很多Intel Math Kernel Library(Intel數學計算核心庫)。而這個IMKL,當然需要配套使用Intel的編譯器了。

我們上傳的編譯器,一般會是個tgz格式的壓縮包。我們找到這個壓縮包的位置,然後在那個位置上解壓:
#tar xzvf l_ccompxe_2011.6.233.tgz

解壓後進入解壓後的資料夾,進行安裝。
#./install.sh
接著會出一個安裝嚮導,我們按提示進行安裝即可。安裝過程中,會提示我們選擇證照,輸入證照的絕對路徑位置即可。

安裝成功後,將得到如下提示:

- Set the environment variables for a terminal window using one of the following
  (replace "intel64" with "ia32" if you are using a 32-bit platform).
     For csh/tcsh:
        $ source install-dir/bin/compilervars.csh intel64
     For bash:
        $ source install-dir/bin/compilervars.sh intel64
     To invoke the installed compilers:
        For C++: icpc
        For C: icc
        For Fortran: ifort
  To get help, append the -help option or precede with the man command.
- To view a table of getting started documents: 
  install-dir/Documentation/en_US/documentation_c.htm.

分別給出了設定環境變數的方法和官方的參考文件的位置。
由於我們採用了預設路徑安裝,所以安裝文件的位置為:
/opt/intel/composerxe/Documentation/en_US/documentation_c.htm

如果你注意觀察的話,會發現在安裝過程中提示的安裝路徑為:composer_xe_2011_sp1。但我們composerxe做為安裝路徑也可以,這是由於composerxe連結到了composer_xe_2011_sp1

設定環境變數

還是由於我們沒有更改安裝路徑,所以環境變數位置應該為:
/opt/intel/composerxe/bin/compilervars.sh intel64

#vi ~/.bashrc

# .bashrc
source /opt/intel/composerxe/bin/compilervars.sh intel64 # 新增這行                   

使環境變數馬上生效(如果有錯誤,執行以下命令時會報錯)
#source ~/.bashrc

安裝l_fcompxe

安裝fcompxe的上面安裝ccompxe一樣。先解壓,再安裝。

安裝openmpi

tar xzvf openmpi-1.6.5.tar.gz
cd openmpi-1.6.5
./configure --prefix="/home/$USER/.openmpi" CC=icc CXX=icpc F77=ifort FC=ifort

--prefix="/home/$USER/.openmpi" 當應用安裝到當前登入使用者的.openmpi資料夾中。CC=icc CXX=icpc F77=ifort FC=ifort為使用哪種編譯器編譯openmpi

make -j1
make install

make -j1使用1核進行編譯;make install 安裝

新增環境變數

export PATH="$PATH:/home/$USER/.openmpi/bin" >> /root/.bashrc
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/$USER/.openmpi/lib/"
>> /root/.bashrc
which mpif90
/home/.openmpi/bin/mpif90

最後一條命令將返回mpif90的1條路徑,即我們上面剛剛設定過的。如果返回了幾行資訊(所有的環境變數路徑,則說明沒有生效)。

注意:以上只適用於docker環境,非docker環境請參考如下配置。

export PATH="$PATH:/home/$USER/.openmpi/bin" >> /home/$USER/.bashrc export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/$USER/.openmpi/lib/"
>> /home/$USER/.bashrc
which mpif90

安裝fftw

tar xzvf fftw-3.3.4.tar.gz 
cd  fftw-3.3.4
./configure --prefix=/home/.fftw --enable-mpi
make -j1
make install

配置環境變數

export PATH=/home/.fftw/bin:$PATH >> /root/.bashrc
export LD_LIBRARY_PATH=/home/.fftw/lib:$LD_LIBRARY_PATH >> /root/.bashrc
which fftw-wisdom
/home/.fftw/bin/fftw-wisdom

注意:非docker環境如下:

export PATH=/home/$USER/.fftw/bin:$PATH >> /home/$USER/.bashrc
export LD_LIBRARY_PATH=/home/USER/.fftw/lib:$LD_LIBRARY_PATH >> /home/$USER/.bashrc
which fftw-wisdom
/home/.fftw/bin/fftw-wisdom

安裝vasp

解壓檔案

在同一資料夾下,分別解壓vasp.5.4.1和vasp.5.lib。

複製並更改配置檔案

cp makefile.include vasp.5.4.1
cd vasp.5.4.1
vi makefile.include
  • 28行設定MKL路徑MKLROOT =/opt/intel/mkl
  • 33行只使用openmpi BLACS =-L$(MKL_PATH) -lmkl_blacs_openmpi_lp64
  • 38行設定fftw OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /home/.fftw/lib/libfftw3_mpi.a
  • 39行設定fftw INCS =-I/home/.fftw/include

上面主要是進行了一些配置,我們需要要給這個配置相應的值。比如mkl在哪了, libffw3_mpi.a的具體位置是什麼,.fftw/include的位置在哪。所以,在設定的同時,我們最好檢視一下本機對應的路徑是否存在。如果不存在,說明位置你記錯了,或是前面哪些步驟你忘了安裝了。

make

萬事具備,在確認伺服器有不小於2G的記憶體後,執行:
make all
然後就是漫長的等待。

新增環境變數

echo export PATH=/home/panjie/vasp.5.4.1/bin:$PATH >> /root/.bashrc
source ~/.bashrc

我們注意到此時,我們設定環境變數使用的是echo xxx >> xx,然後使用source ~/.bashrc生使環境變數生效,這樣做的好處是,當系統重啟後,該環境變數仍然生效。

安裝TorquePBS

該死的vasp_std等命令好像不能直接執行,還需要一個TorquePBS的佇列管理。

安裝依賴

yum install -y libxml2-devel openssl-devel boost-devel libtool openssh-clients

檢視主機名、新建使用者、設定新使用者密碼:

hostname
useradd panjie
passwd panjie

提示框出現後,輸入兩次密碼
得到主機名:28bf0f7e77e6

解壓安裝

tar vxzf torque-6.1.1.1.tar.gz  
cd torque-6.1.1.1
./configure --prefix=/usr/local/torque --with-scp --with-default-server={hostname}
make
make install

將hostname替換成你自己的主機名

配置資訊並啟動服務

cp contrib/init.d/trqauthd /etc/init.d/
chkconfig --add trqauthd
echo /usr/local/lib > /etc/ld.so.conf.d/torque.conf
ldconfig
service trqauthd start

校驗主機名

這步其實前面我們已經做了,重複一遍無所謂了,萬一我們以後更改主機名呢
echo <pbs_server`s_hostname> > /var/spool/torque/server_name
將 <pbs_server`s_hostname> 替換為你的主機名

設定環境變數

echo export PATH=/usr/local/bin/:/usr/local/sbin/:$PATH >> ~/.bashrc
source ~/.bashrc

初始化服務

./torque.setup root

新增節點

如果你是多節點運算,那麼需要將節點資訊新增到:/var/spool/torque/server_priv/nodes

新增開機自啟動並執行demon

cp contrib/init.d/pbs_server /etc/init.d
chkconfig --add pbs_server
service pbs_server restart
cp contrib/init.d/pbs_mom /etc/init.d
chkconfig --add pbs_mom
service pbs_mom start
#cp contrib/init.d/{pbs_{server,sched,mom},trqauthd} /etc/init.d/

# for i in pbs_server pbs_sched pbs_mom trqauthd; do chkconfig --add $i; chkconfig $ion; done

5、在torque的解壓路徑執行./torque.setup panjie時執行下面兩句,設定環境變數

TORQUE=/usr/local/torque-xxx

echo "TORQUE=$TORQUE" >>/etc/profile

echo "export PATH=$PATH:$TORQUE/bin:$TORQUE/sbin" >>/etc/profile

source/etc/profile

./torque.setup panjie

建立自己的映象

前面安裝了這麼多,終於到了可以建立自己的映象的時候。有了自己的映象,將使得我們以後在各種環境下,快速的安裝vasp.

步驟:
0 安裝ssh
1 退出映象
2 commit新映象
3 登入映象倉庫
4 push 映象

exit

# 使用映象

docker pull xxxx:4.5.1
docker run -d –name {containername} -t xxxx:4.5.1 -p 2122:22


再然後,我們可以通過xshell等終端連線執行docker伺服器的2122埠來進行登入了。

# 參考資源
> [https://cndaqiang.github.io/2018/01/09/ubuntu-install-vasp/](https://cndaqiang.github.io/2018/01/09/ubuntu-install-vasp/)

> [https://software.intel.com/en-us/articles/using-intel-compilers-for-linux-under-redhat-enterprise-linux-or-centos](https://software.intel.com/en-us/articles/using-intel-compilers-for-linux-under-redhat-enterprise-linux-or-centos)
> [http://docs.adaptivecomputing.com/torque/5-1-1/Content/topics/hpcSuiteInstall/manual/1-installing/installingTorque.htm](http://docs.adaptivecomputing.com/torque/5-1-1/Content/topics/hpcSuiteInstall/manual/1-installing/installingTorque.htm)

相關文章