From Documentation
Jump to: navigation, search

BIDMach is an interactive environment designed to make it extremely easy to build and use machine learning models.

Installing BIDMach on Graham

BIDMach no longer provide precompiled binaries. User needs to clone BIDMach git repo and install it with Internet connection and no VM limitation. User needs to send email to help@sharcnet.ca to require unlimited VM on Graham login node. (User can also use Cedar's compute node to install BIDMach, with at least 8g memory request, and then copy to Graham).

module load java cuda
git clone http://github.com/BIDData/BIDMach
cd BIDMach
mvn clean install

To run bidmach:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/cvmfs/soft.computecanada.ca/nix/var/nix/profiles/gcc-5.4.0/lib64/:/cvmfs/soft.computecanada.ca/easybuild/software/2017/avx2/Compiler/intel2016.4/cuda/8.0.44/lib64/ 

./bidmach

Running BIDMach on Mosaic and Copper

To run BIDMach interactively, you should ssh to mos1 or submit an interactive job and ssh to the node where your job is running. After login to a dev or compute node, you can go to BIDmach folder and run:

ssh mos1
cd /opt/sharcnet/testing/bidmach/BIDMach_1.0.3-full-linux-x86_64
./bidmach

Installing BIDMach on Mosaic and Copper

BIDMach will be easily installed and run on Mosaic (and Copper) cluster. You can simply download a full bundle from http://bid2.berkeley.edu/bid-data-project/download/ on Mosaic's login node and then decompress it:

[feimao@mos-login feimao]$ wget http://bid2.berkeley.edu/bid-data-project/BIDMach_1.0.3-full-linux-x86_64.tar.gz
[feimao@mos-login feimao]$ tar xf BIDMach_1.0.3-full-linux-x86_64.tar.gz

To make CUDA work, you should create links to cuda's .so library files under BIDMach_1.0.3-full-linux-x86_64/lib/cuda folder

[feimao@mos-login BIDMach_1.0.3-full-linux-x86_64]$ cd lib/cuda/
[feimao@mos-login cuda]$ ln -s libcublas.so libcublas.so.7.0 
[feimao@mos-login cuda]$ ln -s libcudart.so libcudart.so.7.0
[feimao@mos-login cuda]$ ln -s libcurand.so libcurand.so.7.0
[feimao@mos-login cuda]$ ln -s libcusparse.so libcusparse.so.7.0

Then you should login to Mosaic's development node (mos1) and run bidmach from BIDMach's root folder. If you want to display plots, you should also enable X11 window forwarding when login to mosaic and mos1 by adding "-Y" flag to ssh command.

[feimao@mos-login cuda]$ ssh -Y mos1
[feimao@mos1 BIDMach_1.0.3-full-linux-x86_64]$ ./bidmach
Loading /gwork/feimao/BIDMach_1.0.3-full-linux-x86_64/lib/bidmach_init.scala...
import BIDMat.{CMat, CSMat, DMat, Dict, FMat, FND, GMat, GDMat, GIMat, GLMat, GSMat, GSDMat, HMat, IDict, Image, IMat, LMat, Mat, SMat, SBMat, SDMat}
import BIDMat.MatFunctions._
import BIDMat.SciFunctions._
import BIDMat.Solvers._
import BIDMat.Plotting._
import BIDMach.Learner
import BIDMach.models.{FM, GLM, KMeans, KMeansw, LDA, LDAgibbs, Model, NMF, SFA, RandomForest}
import BIDMach.networks.DNN
import BIDMach.datasources.{DataSource, MatDS, FilesDS, SFilesDS}
import BIDMach.mixins.{CosineSim, Perplexity, Top, L1Regularizer, L2Regularizer}
import BIDMach.updaters.{ADAGrad, Batch, BatchNorm, IncMult, IncNorm, Telescoping}
import BIDMach.causal.IPTW
1 CUDA device found, CUDA version 7.0

Welcome to Scala version 2.11.2 (OpenJDK 64-Bit Server VM, Java 1.7.0_85).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 

To test BIDMach, you can run models on data from "/work/feimao/software_installs/BIDMach/BIDMach_1.0.3-full-linux-x86_64/data":

scala> val a = loadSMat("/work/feimao/software_installs/BIDMach/BIDMach_1.0.3-full-linux-x86_64/data/rcv1/docs.smat.lz4")
a: BIDMat.SMat =
(   33,    0)    1
(   47,    0)    1
(   94,    0)    1
(  104,    0)    1
(  112,    0)    3
(  118,    0)    1
(  141,    0)    2
(  165,    0)    2
   ...   ...   ...

scala> val c = loadFMat("/work/feimao/software_installs/BIDMach/BIDMach_1.0.3-full-linux-x86_64/data/rcv1/cats.fmat.lz4")
c: BIDMat.FMat =
   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0...
   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0...
   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0...
   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0...
  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..

scala> val (mm, mopts) = GLM.learner(a, c, 1)
mm: BIDMach.Learner = Learner(BIDMach.datasources.MatDS@4259448a,BIDMach.models.GLM@72a2e20d,[LBIDMach.mixins.Mixin;@23a6fe47,BIDMach.updaters.ADAGrad@287ff99a,BIDMach.models.GLM$LearnOptions@69dc023b)
mopts: BIDMach.models.GLM.LearnOptions = BIDMach.models.GLM$LearnOptions@69dc023b

scala> mm.train
corpus perplexity=5582.125391
pass= 0
 2.00%, ll=-0.69315, gf=2.238, secs=0.3, GB=0.02, MB/s=60.50, GPUmem=0.81
16.00%, ll=-0.12914, gf=9.803, secs=0.9, GB=0.13, MB/s=144.02, GPUmem=0.79
30.00%, ll=-0.12436, gf=11.585, secs=1.5, GB=0.25, MB/s=161.06, GPUmem=0.79
44.00%, ll=-0.09287, gf=12.389, secs=2.1, GB=0.36, MB/s=169.05, GPUmem=0.79
58.00%, ll=-0.08718, gf=12.848, secs=2.7, GB=0.48, MB/s=173.73, GPUmem=0.79
72.00%, ll=-0.06661, gf=13.110, secs=3.3, GB=0.59, MB/s=176.03, GPUmem=0.79
87.00%, ll=-0.07879, gf=13.273, secs=4.0, GB=0.70, MB/s=177.60, GPUmem=0.79
100.00%, ll=-0.06415, gf=13.411, secs=4.5, GB=0.81, MB/s=177.45, GPUmem=0.78
pass= 1
 2.00%, ll=-0.07686, gf=13.432, secs=4.6, GB=0.83, MB/s=179.24, GPUmem=0.78
16.00%, ll=-0.06618, gf=13.547, secs=5.2, GB=0.94, MB/s=180.37, GPUmem=0.78
30.00%, ll=-0.07557, gf=13.636, secs=5.8, GB=1.05, MB/s=181.18, GPUmem=0.78
44.00%, ll=-0.06526, gf=13.714, secs=6.4, GB=1.17, MB/s=181.98, GPUmem=0.78
58.00%, ll=-0.07128, gf=13.773, secs=7.0, GB=1.28, MB/s=182.62, GPUmem=0.78
72.00%, ll=-0.05418, gf=13.808, secs=7.6, GB=1.39, MB/s=182.84, GPUmem=0.78
87.00%, ll=-0.07513, gf=13.855, secs=8.2, GB=1.51, MB/s=183.35, GPUmem=0.78
100.00%, ll=-0.05551, gf=13.893, secs=8.8, GB=1.61, MB/s=182.97, GPUmem=0.78
Time=8.8130 secs, gflops=13.89

scala> val r = mm.results
r: BIDMat.FMat =
   -0.69315   -0.20911  -0.073073  -0.061441  -0.056964  -0.070724  -0.074380  -0.065353  -0.062736  -0.068611  -0.043732  -0.040869  -0.052498  -0.055591...
   -0.69315   -0.36164    -1.8734   -0.37134   -0.38034   -0.28477   -0.47174   -0.28112   -0.30024   -0.26739   -0.49852   -0.25522   -0.47347   -0.25130...
   -0.69315   -0.14747   -0.14184  -0.071280  -0.094481  -0.064610  -0.091037   -0.10561  -0.061054  -0.068009  -0.082601  -0.049113  -0.065837  -0.051656...
   -0.69315   -0.15367   -0.10757  -0.090451  -0.087183  -0.065078  -0.064857  -0.047150  -0.062311  -0.071004  -0.063575  -0.052238  -0.061272  -0.041495...
         ..         ..         ..         ..         ..         ..         ..         ..         ..         ..         ..         ..         ..     ...
scala> plot(r(0,?))
res3: ptolemy.plot.Plot = ptolemy.plot.Plot[,0,0,490x249,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777225,maximumSize=,minimumSize=,preferredSize=]