Linux下好用的module管理工具

1.What's module manager

environment-modules是一個用于管理用戶不同應(yīng)用的工具,可以動態(tài)的加載、移除所安裝的應(yīng)用。

2.How to install

在ubuntu系統(tǒng)下,安裝十分簡單:

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里面設(shè)置一下環(huán)境變量,指定modulefiles的路徑,module這個應(yīng)用就是通過modulefiles來定位安裝的軟件的位置以及其他路徑與環(huán)境變量的設(shè)置。

export MODULEPATH=/opt/modulefiles

下面就需要去該路徑編輯modulefiles了,一個簡單的modulefiles如下:

#%Module1.0
conflict caffe #指示沖突的程序名,其他的modulefiles不能再使用這個名字
set installdir /home/manager/caffe #tcl的局部變量,只在該tcl文件中生效
setenv CAFFE_ROOT    $installdir #使用局部變量進(jìn)行全局環(huán)境變量的設(shè)置
setenv CAFFE_INCLUDE $installdir/include
setenv CAFFE_LIB     $installdir/build/lib
prepend-path PATH    $installdir/build/tools #前路徑,一般設(shè)置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之后,就可以動態(tài)的加載應(yīng)用了:

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對應(yīng)的modulefiles如下:

#%Module1.0
conflict HelloModule
set installdir /opt/HelloModule
prepend-path PATH    $installdir
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容