1.What's module manager
environment-modules是一個用于管理用戶不同應用的工具,可以動態的加載、移除所安裝的應用。
2.How to install
在ubuntu系統下,安裝十分簡單:
sudo apt-cache search environment-modules #search the module
sudo apt-get install environment-modules # install the module
3.How to use
安裝environment-modules之后,需要在.bashrc里面設置一下環境變量,指定modulefiles的路徑,module這個應用就是通過modulefiles來定位安裝的軟件的位置以及其他路徑與環境變量的設置。
export MODULEPATH=/opt/modulefiles
下面就需要去該路徑編輯modulefiles了,一個簡單的modulefiles如下:
#%Module1.0
conflict caffe #指示沖突的程序名,其他的modulefiles不能再使用這個名字
set installdir /home/manager/caffe #tcl的局部變量,只在該tcl文件中生效
setenv CAFFE_ROOT $installdir #使用局部變量進行全局環境變量的設置
setenv CAFFE_INCLUDE $installdir/include
setenv CAFFE_LIB $installdir/build/lib
prepend-path PATH $installdir/build/tools #前路徑,一般設置prepend即可
prepend-path PYTHONPATH $installdir/python
# caffe需要第三方庫的支持
prepend-path LD_LIBRARY_PATH /opt/intel/mkl/lib/intel64
prepend-path LD_LIBRARY_PATH $installdir/build/lib
編輯好了modulefiles之后,就可以動態的加載應用了:
root@artosyn-vision:/opt/modulefiles# module avail
----------------------------------------- /opt/modulefiles --------------------------------
anaconda3 HelloModule caffe
root@artosyn-vision:/opt/modulefiles# module load HelloModule
root@artosyn-vision:/opt/modulefiles# HelloModule
I use this bin file to test module
HelloModule ~~~~~~~~~~~
HelloModule.cpp的代碼如下:
#include <stdio.h>
int main()
{
printf("I use this bin file to test module\n");
printf("HelloModule ~~~~~~~~~~~\n");
return 0;
}
HelloModule對應的modulefiles如下:
#%Module1.0
conflict HelloModule
set installdir /opt/HelloModule
prepend-path PATH $installdir