2017년 11월 9일 목요일

R 3.4.1의 설치 및 기존 rstudio와의 연동

예전에 쓰던 버전의 R (가령 3.3.2)를 그대로 놔둔 상태에서, 새로운 버전의 R 3.4.1을 써야 할 경우가 있습니다.  이때는 아래 절차에 따라 설치하시면 됩니다.

먼저, 아래 link에서 제가 ppc64le(POWER8) 상에서 빌드한 R server 3.4.1을 여기서 download 받아서, 기존 서버의 사용자 홈 디렉토리에 upload 한 뒤 자신의 홈 디렉토리에 풀어놓습니다. 
여기서는 u0017649라는 유저의 홈디렉토리에 풀었습니다만, 아무 곳에 풀어놓아도 상관없습니다.   기존 버전은 /usr/local/lib/R 밑에 설치되어 있을 것입니다.

u0017649@sys-89830:~$ tar -zxf R341.tgz

u0017649@sys-89830:~$ cd R
u0017649@sys-89830:~/R$ pwd
/home/u0017649/R

이제 새로 풀어놓은 R을 Rstudio와 연동시키기 위해서, 다음과 같이 기존 /usr/bin/R을 다음과 같이 옮겨놓고, 방금 풀어놓은 R을 /usr/bin/R로 softlink를 시켜 줍니다.

u0017649@sys-89830:~/R$ sudo mv /usr/bin/R /usr/bin/R.old

u0017649@sys-89830:~/R$ sudo ln /home/u0017649/R/bin/R /usr/bin/R

이제 Rstudio를 재시작합니다.

u0017649@sys-89830:~/R$ sudo systemctl stop rstudio-server.service
u0017649@sys-89830:~/R$ sudo systemctl start rstudio-server.service

u0017649@sys-89830:~/R$ sudo systemctl status rstudio-server.service
● rstudio-server.service - LSB: RStudio Server
   Loaded: loaded (/etc/init.d/rstudio-server; bad; vendor preset: enabled)
   Active: active (running) since Wed 2017-11-08 20:26:40 EST; 7s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 12456 ExecStop=/etc/init.d/rstudio-server stop (code=exited, status=0/SUCCESS)
  Process: 12469 ExecStart=/etc/init.d/rstudio-server start (code=exited, status=0/SUCCESS)
    Tasks: 3
   Memory: 10.1M
      CPU: 661ms
   CGroup: /system.slice/rstudio-server.service
           └─12477 /usr/local/lib/rstudio-server/bin/rserver

Nov 08 20:26:40 sys-89830 systemd[1]: Starting LSB: RStudio Server...
Nov 08 20:26:40 sys-89830 systemd[1]: Started LSB: RStudio Server.

그 다음에 평소대로 http://서버주소:8787 로 접속하시면 됩니다.  아래와 같이 잘 됩니다.



참고1) 기존 Rstudio 버전(Version 99.9.9)은 새 R 3.4.1과 위와 같이 잘 연동됩니다.

참고2) 여기서 사용된 CRAN R 3.4.1의 빌드는 예전 포스팅 http://hwengineer.blogspot.kr/2017/06/ppc64le-ubuntu-cran-r-package-rstudio.html 에 나온 절차대로 하시면 됩니다. 

참고3) 이 R341.tgz 속에 설치된 R 패키지들은 다음과 같습니다.

> installed.packages()
              Package        
anim.plots    "anim.plots"   
animation     "animation"    
assertthat    "assertthat"   
BH            "BH"           
bindr         "bindr"        
bindrcpp      "bindrcpp"     
bitops        "bitops"       
boot          "boot"         
Boruta        "Boruta"       
caret         "caret"        
caretEnsemble "caretEnsemble"
caTools       "caTools"      
class         "class"        
cluster       "cluster"      
codetools     "codetools"    
colorspace    "colorspace"   
curl          "curl"         
CVST          "CVST"         
data.table    "data.table"   
ddalpha       "ddalpha"      
DEoptimR      "DEoptimR"     
dichromat     "dichromat"    
digest        "digest"       
dimRed        "dimRed"       
dplyr         "dplyr"        
DRR           "DRR"          
e1071         "e1071"        
evaluate      "evaluate"     
foreach       "foreach"      
foreign       "foreign"      
gdata         "gdata"        
ggplot2       "ggplot2"      
glue          "glue"         
gower         "gower"        
gplots        "gplots"       
gridExtra     "gridExtra"    
gtable        "gtable"       
gtools        "gtools"       
highr         "highr"        
ipred         "ipred"        
iterators     "iterators"    
kernlab       "kernlab"      
KernSmooth    "KernSmooth"   
knitr         "knitr"        
labeling      "labeling"     
lattice       "lattice"      
lava          "lava"         
lazyeval      "lazyeval"     
lubridate     "lubridate"    
magrittr      "magrittr"     
markdown      "markdown"     
MASS          "MASS"         
Matrix        "Matrix"       
mgcv          "mgcv"         
mime          "mime"         
ModelMetrics  "ModelMetrics" 
munsell       "munsell"      
nlme          "nlme"         
numDeriv      "numDeriv"     
pbapply       "pbapply"      
pkgconfig     "pkgconfig"    
plogr         "plogr"        
              LibPath                        
anim.plots    "/usr/local/lib/R/site-library"
animation     "/usr/local/lib/R/site-library"
assertthat    "/usr/local/lib/R/site-library"
BH            "/usr/local/lib/R/site-library"
bindr         "/usr/local/lib/R/site-library"
bindrcpp      "/usr/local/lib/R/site-library"
bitops        "/usr/local/lib/R/site-library"
boot          "/usr/local/lib/R/site-library"
Boruta        "/usr/local/lib/R/site-library"
caret         "/usr/local/lib/R/site-library"
caretEnsemble "/usr/local/lib/R/site-library"
caTools       "/usr/local/lib/R/site-library"
class         "/usr/local/lib/R/site-library"
cluster       "/usr/local/lib/R/site-library"
codetools     "/usr/local/lib/R/site-library"
colorspace    "/usr/local/lib/R/site-library"
curl          "/usr/local/lib/R/site-library"
CVST          "/usr/local/lib/R/site-library"
data.table    "/usr/local/lib/R/site-library"
ddalpha       "/usr/local/lib/R/site-library"
DEoptimR      "/usr/local/lib/R/site-library"
dichromat     "/usr/local/lib/R/site-library"
digest        "/usr/local/lib/R/site-library"
dimRed        "/usr/local/lib/R/site-library"
dplyr         "/usr/local/lib/R/site-library"
DRR           "/usr/local/lib/R/site-library"
e1071         "/usr/local/lib/R/site-library"
evaluate      "/usr/local/lib/R/site-library"
foreach       "/usr/local/lib/R/site-library"
foreign       "/usr/local/lib/R/site-library"
gdata         "/usr/local/lib/R/site-library"
ggplot2       "/usr/local/lib/R/site-library"
glue          "/usr/local/lib/R/site-library"
gower         "/usr/local/lib/R/site-library"
gplots        "/usr/local/lib/R/site-library"
gridExtra     "/usr/local/lib/R/site-library"
gtable        "/usr/local/lib/R/site-library"
gtools        "/usr/local/lib/R/site-library"
highr         "/usr/local/lib/R/site-library"
ipred         "/usr/local/lib/R/site-library"
iterators     "/usr/local/lib/R/site-library"
kernlab       "/usr/local/lib/R/site-library"
KernSmooth    "/usr/local/lib/R/site-library"
knitr         "/usr/local/lib/R/site-library"
labeling      "/usr/local/lib/R/site-library"
lattice       "/usr/local/lib/R/site-library"
lava          "/usr/local/lib/R/site-library"
lazyeval      "/usr/local/lib/R/site-library"
lubridate     "/usr/local/lib/R/site-library"
magrittr      "/usr/local/lib/R/site-library"
markdown      "/usr/local/lib/R/site-library"
MASS          "/usr/local/lib/R/site-library"
Matrix        "/usr/local/lib/R/site-library"
mgcv          "/usr/local/lib/R/site-library"
mime          "/usr/local/lib/R/site-library"
ModelMetrics  "/usr/local/lib/R/site-library"
munsell       "/usr/local/lib/R/site-library"
nlme          "/usr/local/lib/R/site-library"
numDeriv      "/usr/local/lib/R/site-library"
pbapply       "/usr/local/lib/R/site-library"
pkgconfig     "/usr/local/lib/R/site-library"
plogr         "/usr/local/lib/R/site-library"
              Version     Priority     
anim.plots    "0.2"       NA           
animation     "2.5"       NA           
assertthat    "0.2.0"     NA           
BH            "1.65.0-1"  NA           
bindr         "0.1"       NA           
bindrcpp      "0.2"       NA           
bitops        "1.0-6"     NA           
boot          "1.3-20"    "recommended"
Boruta        "5.2.0"     NA           
caret         "6.0-77"    NA           
caretEnsemble "2.0.0"     NA           
caTools       "1.17.1"    NA           
class         "7.3-14"    "recommended"
cluster       "2.0.6"     "recommended"
codetools     "0.2-15"    "recommended"
colorspace    "1.3-2"     NA           
curl          "3.0"       NA           
CVST          "0.2-1"     NA           
data.table    "1.10.4-3"  NA           
ddalpha       "1.3.1"     NA           
DEoptimR      "1.0-8"     NA           
dichromat     "2.0-0"     NA           
digest        "0.6.12"    NA           
dimRed        "0.1.0"     NA           
dplyr         "0.7.4"     NA           
DRR           "0.0.2"     NA           
e1071         "1.6-8"     NA           
evaluate      "0.10.1"    NA           
foreach       "1.4.3"     NA           
foreign       "0.8-69"    "recommended"
gdata         "2.18.0"    NA           
ggplot2       "2.2.1"     NA           
glue          "1.2.0"     NA           
gower         "0.1.2"     NA           
gplots        "3.0.1"     NA           
gridExtra     "2.3"       NA           
gtable        "0.2.0"     NA           
gtools        "3.5.0"     NA           
highr         "0.6"       NA           
ipred         "0.9-6"     NA           
iterators     "1.0.8"     NA           
kernlab       "0.9-25"    NA           
KernSmooth    "2.23-15"   "recommended"
knitr         "1.17"      NA           
labeling      "0.3"       NA           
lattice       "0.20-35"   "recommended"
lava          "1.5.1"     NA           
lazyeval      "0.2.1"     NA           
lubridate     "1.7.1"     NA           
magrittr      "1.5"       NA           
markdown      "0.8"       NA           
MASS          "7.3-47"    "recommended"
Matrix        "1.2-11"    "recommended"
mgcv          "1.8-22"    "recommended"
mime          "0.5"       NA           
ModelMetrics  "1.1.0"     NA           
munsell       "0.4.3"     NA           
nlme          "3.1-131"   "recommended"
numDeriv      "2016.8-1"  NA           
pbapply       "1.3-3"     NA           
pkgconfig     "2.0.1"     NA           
plogr         "0.1-1"     NA           
              Depends                                                               
anim.plots    NA                                                                    
animation     "R (>= 2.14.0)"                                                       
assertthat    NA                                                                    
BH            NA                                                                    
bindr         NA                                                                    
bindrcpp      NA                                                                    
bitops        NA                                                                    
boot          "R (>= 3.0.0), graphics, stats"                                       
Boruta        "ranger"                                                              
caret         "R (>= 2.10), lattice (>= 0.20), ggplot2"                             
caretEnsemble "R (>= 3.2.0)"                                                        
caTools       "R (>= 2.2.0)"                                                        
class         "R (>= 3.0.0), stats, utils"                                          
cluster       "R (>= 3.0.1)"                                                        
codetools     "R (>= 2.1)"                                                          
colorspace    "R (>= 2.13.0), methods"                                              
curl          "R (>= 3.0.0)"                                                        
CVST          "kernlab,Matrix"                                                      
data.table    "R (>= 3.0.0)"                                                        
ddalpha       "stats, utils, graphics, grDevices, MASS, class, robustbase,\nsfsmisc"
DEoptimR      NA                                                                    
dichromat     "R (>= 2.10), stats"                                                  
digest        "R (>= 2.4.1)"                                                        
dimRed        "R (>= 3.0.0), methods, DRR"                                          
dplyr         "R (>= 3.1.2)"                                                        
DRR           "kernlab, CVST, Matrix"                                               
e1071         NA                                                                    
evaluate      "R (>= 3.0.2)"                                                        
foreach       "R (>= 2.5.0)"                                                        
foreign       "R (>= 3.0.0)"                                                        
gdata         "R (>= 2.3.0)"                                                        
ggplot2       "R (>= 3.1)"                                                          
glue          "R (>= 3.1)"                                                          
gower         NA                                                                    
gplots        "R (>= 3.0)"                                                          
gridExtra     NA                                                                    
gtable        "R (>= 2.14)"                                                         
gtools        "R (>= 2.10)"                                                         
highr         "R (>= 3.0.2)"                                                        
ipred         "R (>= 2.10)"                                                         
iterators     "R (>= 2.5.0), utils"                                                 
kernlab       "R (>= 2.10)"                                                         
KernSmooth    "R (>= 2.5.0), stats"                                                 
knitr         "R (>= 3.1.0)"                                                        
labeling      NA                                                                    
lattice       "R (>= 3.0.0)"                                                        
lava          "R (>= 3.0)"                                                          
lazyeval      "R (>= 3.1.0)"                                                        
lubridate     "methods, R (>= 3.0.0)"                                               
magrittr      NA                                                                    
markdown      "R (>= 2.11.1)"                                                       
MASS          "R (>= 3.1.0), grDevices, graphics, stats, utils"                     
Matrix        "R (>= 3.0.1)"                                                        
mgcv          "R (>= 2.14.0), nlme (>= 3.1-64)"                                     
mime          NA                                                                    
ModelMetrics  "R (>= 3.2.2)"                                                        
munsell       NA                                                                    
nlme          "R (>= 3.0.2)"                                                        
numDeriv      "R (>= 2.11.1)"                                                       
pbapply       "R (>= 3.2.0)"                                                        
pkgconfig     NA                                                                    
plogr         NA                                                                    
              Imports                                                                                                                                             
anim.plots    "animation"                                                                                                                                         
animation     NA                                                                                                                                                  
assertthat    "tools"                                                                                                                                             
BH            NA                                                                                                                                                  
bindr         NA                                                                                                                                                  
bindrcpp      "Rcpp, bindr"                                                                                                                                       
bitops        NA                                                                                                                                                  
boot          NA                                                                                                                                                  
Boruta        NA                                                                                                                                                  
caret         "foreach, methods, plyr, ModelMetrics (>= 1.1.0), nlme,\nreshape2, stats, stats4, utils, grDevices, recipes (>= 0.0.1),\nwithr (>= 2.0.0)"          
caretEnsemble "methods, pbapply, ggplot2, digest, plyr, lattice, gridExtra,\ndata.table, caret"                                                                   
caTools       "bitops"                                                                                                                                            
class         "MASS"                                                                                                                                              
cluster       "graphics, grDevices, stats, utils"                                                                                                                 
codetools     NA                                                                                                                                                  
colorspace    "graphics, grDevices"                                                                                                                               
curl          NA                                                                                                                                                  
CVST          NA                                                                                                                                                  
data.table    "methods"                                                                                                                                           
ddalpha       "Rcpp (>= 0.11.0)"                                                                                                                                  
DEoptimR      "stats"                                                                                                                                             
dichromat     NA                                                                                                                                                  
digest        NA                                                                                                                                                  
dimRed        NA                                                                                                                                                  
dplyr         "assertthat, bindrcpp (>= 0.2), glue (>= 1.1.1), magrittr,\nmethods, pkgconfig, rlang (>= 0.1.2), R6, Rcpp (>= 0.12.7),\ntibble (>= 1.3.1), utils"  
DRR           "stats, methods"                                                                                                                                    
e1071         "graphics, grDevices, class, stats, methods, utils"                                                                                                 
evaluate      "methods, stringr (>= 0.6.2)"                                                                                                                       
foreach       "codetools, utils, iterators"                                                                                                                       
foreign       "methods, utils, stats"                                                                                                                             
gdata         "gtools, stats, methods, utils"                                                                                                                     
ggplot2       "digest, grid, gtable (>= 0.1.1), MASS, plyr (>= 1.7.1),\nreshape2, scales (>= 0.4.1), stats, tibble, lazyeval"                                     
glue          "methods"                                                                                                                                           
gower         NA                                                                                                                                                  
gplots        "gtools, gdata, stats, caTools, KernSmooth"                                                                                                         
gridExtra     "gtable, grid, grDevices, graphics, utils"                                                                                                          
gtable        "grid"                                                                                                                                              
gtools        NA                                                                                                                                                  
highr         NA                                                                                                                                                  
ipred         "rpart (>= 3.1-8), MASS, survival, nnet, class, prodlim"                                                                                            
iterators     NA                                                                                                                                                  
kernlab       "methods, stats, grDevices, graphics"                                                                                                               
KernSmooth    NA                                                                                                                                                  
knitr         "evaluate (>= 0.10), digest, highr, markdown, stringr (>= 0.6),\nyaml, methods, tools"                                                              
labeling      NA                                                                                                                                                  
lattice       "grid, grDevices, graphics, stats, utils"                                                                                                           
lava          "grDevices, graphics, methods, numDeriv, stats, survival, utils"                                                                                    
lazyeval      NA                                                                                                                                                  
lubridate     "stringr, Rcpp (>= 0.11),"                                                                                                                          
magrittr      NA                                                                                                                                                  
markdown      "utils, mime (>= 0.3)"                                                                                                                              
MASS          "methods"                                                                                                                                           
Matrix        "methods, graphics, grid, stats, utils, lattice"                                                                                                    
mgcv          "methods, stats, graphics, Matrix"                                                                                                                  
mime          "tools"                                                                                                                                             
ModelMetrics  "Rcpp"                                                                                                                                              
munsell       "colorspace, methods"                                                                                                                               
nlme          "graphics, stats, utils, lattice"                                                                                                                   
numDeriv      NA                                                                                                                                                  
pbapply       "parallel"                                                                                                                                          
pkgconfig     "utils"                                                                                                                                             
plogr         NA                                                                                                                                                  
              LinkingTo                                            
anim.plots    NA                                                   
animation     NA                                                   
assertthat    NA                                                   
BH            NA                                                   
bindr         NA                                                   
bindrcpp      "Rcpp, plogr"                                        
bitops        NA                                                   
boot          NA                                                   
Boruta        NA                                                   
caret         NA                                                   
caretEnsemble NA                                                   
caTools       NA                                                   
class         NA                                                   
cluster       NA                                                   
codetools     NA                                                   
colorspace    NA                                                   
curl          NA                                                   
CVST          NA                                                   
data.table    NA                                                   
ddalpha       "BH, Rcpp"                                           
DEoptimR      NA                                                   
dichromat     NA                                                   
digest        NA                                                   
dimRed        NA                                                   
dplyr         "Rcpp (>= 0.12.0), BH (>= 1.58.0-1), bindrcpp, plogr"
DRR           NA                                                   
e1071         NA                                                   
evaluate      NA                                                   
foreach       NA                                                   
foreign       NA                                                   
gdata         NA                                                   
ggplot2       NA                                                   
glue          NA                                                   
gower         NA                                                   
gplots        NA                                                   
gridExtra     NA                                                   
gtable        NA                                                   
gtools        NA                                                   
highr         NA                                                   
ipred         NA                                                   
iterators     NA                                                   
kernlab       NA                                                   
KernSmooth    NA                                                   
knitr         NA                                                   
labeling      NA                                                   
lattice       NA                                                   
lava          NA                                                   
lazyeval      NA                                                   
lubridate     "Rcpp,"                                              
magrittr      NA                                                   
markdown      NA                                                   
MASS          NA                                                   
Matrix        NA                                                   
mgcv          NA                                                   
mime          NA                                                   
ModelMetrics  "Rcpp"                                               
munsell       NA                                                   
nlme          NA                                                   
numDeriv      NA                                                   
pbapply       NA                                                   
pkgconfig     NA                                                   
plogr         NA                                                   
              Suggests                                                                                                                                                                                                                                                     
anim.plots    "maps, knitr, mapdata, testthat"                                                                                                                                                                                                                             
animation     "MASS, class, testit"                                                                                                                                                                                                                                        
assertthat    "testthat"                                                                                                                                                                                                                                                   
BH            NA                                                                                                                                                                                                                                                           
bindr         "testthat"                                                                                                                                                                                                                                                   
bindrcpp      "testthat"                                                                                                                                                                                                                                                   
bitops        NA                                                                                                                                                                                                                                                           
boot          "MASS, survival"                                                                                                                                                                                                                                             
Boruta        "mlbench, rFerns, randomForest"                                                                                                                                                                                                                              
caret         "BradleyTerry2, e1071, earth (>= 2.2-3), fastICA, gam, ipred,\nkernlab, klaR, MASS, ellipse, mda, mgcv, mlbench, MLmetrics,\nnnet, party (>= 0.9-99992), pls, pROC, proxy, randomForest,\nRANN, spls, subselect, pamr, superpc, Cubist, testthat (>=\n0.9.1)"
caretEnsemble "caTools, testthat, lintr, randomForest, glmnet, rpart,\nkernlab, nnet, e1071, ipred, pROC, knitr, mlbench, MASS, gbm,\nklaR"                                                                                                                                
caTools       "MASS, rpart"                                                                                                                                                                                                                                                
class         NA                                                                                                                                                                                                                                                           
cluster       "MASS"                                                                                                                                                                                                                                                       
codetools     NA                                                                                                                                                                                                                                                           
colorspace    "datasets, stats, utils, KernSmooth, MASS, kernlab, mvtnorm,\nvcd, dichromat, tcltk, shiny, shinyjs"                                                                                                                                                         
curl          "testthat (>= 1.0.0), knitr, jsonlite, rmarkdown, magrittr,\nhttpuv, webutils"                                                                                                                                                                               
CVST          NA                                                                                                                                                                                                                                                           
data.table    "bit64, knitr, nanotime, chron, ggplot2 (>= 0.9.0), plyr,\nreshape, reshape2, testthat (>= 0.4), hexbin, fastmatch, nlme,\nxts, gdata, GenomicRanges, caret, curl, zoo, plm, rmarkdown,\nparallel"                                                           
ddalpha       NA                                                                                                                                                                                                                                                           
DEoptimR      NA                                                                                                                                                                                                                                                           
dichromat     NA                                                                                                                                                                                                                                                           
digest        "knitr, rmarkdown"                                                                                                                                                                                                                                           
dimRed        "MASS, Matrix, RANN, RSpectra, Rtsne, coRanking, diffusionMap,\nenergy, fastICA, ggplot2, graphics, igraph, kernlab, lle, loe,\noptimx, pcaPP, rgl, scales, scatterplot3d, stats, testthat,\ntidyr, vegan"                                                   
dplyr         "bit64, covr, dbplyr, dtplyr, DBI, ggplot2, hms, knitr, Lahman\n(>= 3.0-1), mgcv, microbenchmark, nycflights13, rmarkdown,\nRMySQL, RPostgreSQL, RSQLite, testthat, withr"                                                                                   
DRR           "knitr"                                                                                                                                                                                                                                                      
e1071         "cluster, mlbench, nnet, randomForest, rpart, SparseM, xtable,\nMatrix, MASS"                                                                                                                                                                                
evaluate      "testthat, lattice, ggplot2"                                                                                                                                                                                                                                 
foreach       "randomForest"                                                                                                                                                                                                                                               
foreign       NA                                                                                                                                                                                                                                                           
gdata         "RUnit"                                                                                                                                                                                                                                                      
ggplot2       "covr, ggplot2movies, hexbin, Hmisc, lattice, mapproj, maps,\nmaptools, mgcv, multcomp, nlme, testthat (>= 0.11.0), quantreg,\nknitr, rpart, rmarkdown, svglite"                                                                                             
glue          "testthat, covr, magrittr, crayon, knitr, rmarkdown, DBI,\nRSQLite, R.utils, forcats, microbenchmark, rprintf, stringr,\nggplot2"                                                                                                                            
gower         "testthat, knitr, rmarkdown"                                                                                                                                                                                                                                 
gplots        "grid, MASS"                                                                                                                                                                                                                                                 
gridExtra     "ggplot2, egg, lattice, knitr, testthat"                                                                                                                                                                                                                     
gtable        "testthat, covr"                                                                                                                                                                                                                                             
gtools        NA                                                                                                                                                                                                                                                           
highr         "knitr, testit"                                                                                                                                                                                                                                              
ipred         "mvtnorm, mlbench, TH.data"                                                                                                                                                                                                                                  
iterators     "RUnit"                                                                                                                                                                                                                                                      
kernlab       NA                                                                                                                                                                                                                                                           
KernSmooth    "MASS"                                                                                                                                                                                                                                                       
knitr         "formatR, testit, rgl (>= 0.95.1201), codetools, rmarkdown,\nhtmlwidgets (>= 0.7), webshot, tikzDevice (>= 0.10), png, jpeg,\nXML, RCurl, DBI (>= 0.4-1), tibble"                                                                                            
labeling      NA                                                                                                                                                                                                                                                           
lattice       "KernSmooth, MASS, latticeExtra"                                                                                                                                                                                                                             
lava          "KernSmooth, Matrix, Rgraphviz, ascii, data.table, fields,\nforeach, geepack, gof (>= 0.9), graph, igraph (>= 0.6),\nlava.tobit, lme4, mets (>= 1.1), optimx, quantreg, rgl,\ntestthat (>= 0.11), visNetwork, zoo"                                           
lazyeval      "knitr, rmarkdown (>= 0.2.65), testthat, covr"                                                                                                                                                                                                               
lubridate     "testthat, knitr, covr"                                                                                                                                                                                                                                      
magrittr      "testthat, knitr"                                                                                                                                                                                                                                            
markdown      "knitr, RCurl"                                                                                                                                                                                                                                               
MASS          "lattice, nlme, nnet, survival"                                                                                                                                                                                                                              
Matrix        "expm, MASS"                                                                                                                                                                                                                                                 
mgcv          "splines, parallel, survival, MASS"                                                                                                                                                                                                                          
mime          NA                                                                                                                                                                                                                                                           
ModelMetrics  "testthat"                                                                                                                                                                                                                                                   
munsell       "ggplot2, testthat"                                                                                                                                                                                                                                          
nlme          "Hmisc, MASS"                                                                                                                                                                                                                                                
numDeriv      NA                                                                                                                                                                                                                                                           
pbapply       NA                                                                                                                                                                                                                                                           
pkgconfig     "covr, testthat, disposables (>= 1.0.3)"                                                                                                                                                                                                                     
plogr         "Rcpp"                                                                                                                                                                                                                                                       
              Enhances                                                  
anim.plots    NA                                                        
animation     NA                                                        
assertthat    NA                                                        
BH            NA                                                        
bindr         NA                                                        
bindrcpp      NA                                                        
bitops        NA                                                        
boot          NA                                                        
Boruta        NA                                                        
caret         NA                                                        
caretEnsemble NA                                                        
caTools       NA                                                        
class         NA                                                        
cluster       NA                                                        
codetools     NA                                                        
colorspace    NA                                                        
curl          NA                                                        
CVST          NA                                                        
data.table    NA                                                        
ddalpha       NA                                                        
DEoptimR      "robustbase"                                              
dichromat     NA                                                        
digest        NA                                                        
dimRed        NA                                                        
dplyr         NA                                                        
DRR           NA                                                        
e1071         NA                                                        
evaluate      NA                                                        
foreach       "compiler, doMC, RUnit, doParallel"                       
foreign       NA                                                        
gdata         NA                                                        
ggplot2       "sp"                                                      
glue          NA                                                        
gower         NA                                                        
gplots        NA                                                        
gridExtra     NA                                                        
gtable        NA                                                        
gtools        NA                                                        
highr         NA                                                        
ipred         NA                                                        
iterators     NA                                                        
kernlab       NA                                                        
KernSmooth    NA                                                        
knitr         NA                                                        
labeling      NA                                                        
lattice       "chron"                                                   
lava          NA                                                        
lazyeval      NA                                                        
lubridate     "chron, fts, timeSeries, timeDate, tis, tseries, xts, zoo"
magrittr      NA                                                        
markdown      NA                                                        
MASS          NA                                                        
Matrix        "MatrixModels, graph, SparseM, sfsmisc"                   
mgcv          NA                                                        
mime          NA                                                        
ModelMetrics  NA                                                        
munsell       NA                                                        
nlme          NA                                                        
numDeriv      NA                                                        
pbapply       NA                                                        
pkgconfig     NA                                                        
plogr         NA                                                        
              License                         
anim.plots    "GPL-2"                         
animation     "GPL"                           
assertthat    "GPL-3"                         
BH            "BSL-1.0"                       
bindr         "MIT + file LICENSE"            
bindrcpp      "MIT + file LICENSE"            
bitops        "GPL (>= 2)"                    
boot          "Unlimited"                     
Boruta        "GPL (>= 2)"                    
caret         "GPL (>= 2)"                    
caretEnsemble "MIT + file LICENSE"            
caTools       "GPL-3"                         
class         "GPL-2 | GPL-3"                 
cluster       "GPL (>= 2)"                    
codetools     "GPL"                           
colorspace    "BSD_3_clause + file LICENSE"   
curl          "MIT + file LICENSE"            
CVST          "GPL (>= 2.0)"                  
data.table    "GPL-3 | file LICENSE"          
ddalpha       "GPL-2"                         
DEoptimR      "GPL (>= 2)"                    
dichromat     "GPL-2"                         
digest        "GPL (>= 2)"                    
dimRed        "GPL-3 | file LICENSE"          
dplyr         "MIT + file LICENSE"            
DRR           "GPL-3"                         
e1071         "GPL-2"                         
evaluate      "MIT + file LICENSE"            
foreach       "Apache License (== 2.0)"       
foreign       "GPL (>= 2)"                    
gdata         "GPL-2"                         
ggplot2       "GPL-2 | file LICENSE"          
glue          "MIT + file LICENSE"            
gower         "GPL-3"                         
gplots        "GPL-2"                         
gridExtra     "GPL (>= 2)"                    
gtable        "GPL-2"                         
gtools        "GPL-2"                         
highr         "GPL"                           
ipred         "GPL (>= 2)"                    
iterators     "Apache License (== 2.0)"       
kernlab       "GPL-2"                         
KernSmooth    "Unlimited"                     
knitr         "GPL"                           
labeling      "MIT + file LICENSE | Unlimited"
lattice       "GPL (>= 2)"                    
lava          "GPL-3"                         
lazyeval      "GPL-3"                         
lubridate     "GPL-2"                         
magrittr      "MIT + file LICENSE"            
markdown      "GPL-2"                         
MASS          "GPL-2 | GPL-3"                 
Matrix        "GPL (>= 2) | file LICENCE"     
mgcv          "GPL (>= 2)"                    
mime          "GPL"                           
ModelMetrics  "GPL (>= 2)"                    
munsell       "MIT + file LICENSE"            
nlme          "GPL (>= 2) | file LICENCE"     
numDeriv      "GPL-2"                         
pbapply       "GPL-2"                         
pkgconfig     "MIT + file LICENSE"            
plogr         "MIT + file LICENSE"            
              License_is_FOSS
anim.plots    NA             
animation     NA             
assertthat    NA             
BH            NA             
bindr         NA             
bindrcpp      NA             
bitops        NA             
boot          NA             
Boruta        NA             
caret         NA             
caretEnsemble NA             
caTools       NA             
class         NA             
cluster       NA             
codetools     NA             
colorspace    NA             
curl          NA             
CVST          NA             
data.table    NA             
ddalpha       NA             
DEoptimR      NA             
dichromat     NA             
digest        NA             
dimRed        NA             
dplyr         NA             
DRR           NA             
e1071         NA             
evaluate      NA             
foreach       NA             
foreign       NA             
gdata         NA             
ggplot2       NA             
glue          NA             
gower         NA             
gplots        NA             
gridExtra     NA             
gtable        NA             
gtools        NA             
highr         NA             
ipred         NA             
iterators     NA             
kernlab       NA             
KernSmooth    NA             
knitr         NA             
labeling      NA             
lattice       NA             
lava          NA             
lazyeval      NA             
lubridate     NA             
magrittr      NA             
markdown      NA             
MASS          NA             
Matrix        NA             
mgcv          NA             
mime          NA             
ModelMetrics  NA             
munsell       NA             
nlme          NA             
numDeriv      NA             
pbapply       NA             
pkgconfig     NA             
plogr         NA             
              License_restricts_use OS_type
anim.plots    NA                    NA     
animation     NA                    NA     
assertthat    NA                    NA     
BH            NA                    NA     
bindr         NA                    NA     
bindrcpp      NA                    NA     
bitops        NA                    NA     
boot          NA                    NA     
Boruta        NA                    NA     
caret         NA                    NA     
caretEnsemble NA                    NA     
caTools       NA                    NA     
class         NA                    NA     
cluster       NA                    NA     
codetools     NA                    NA     
colorspace    NA                    NA     
curl          NA                    NA     
CVST          NA                    NA     
data.table    NA                    NA     
ddalpha       NA                    NA     
DEoptimR      NA                    NA     
dichromat     NA                    NA     
digest        NA                    NA     
dimRed        NA                    NA     
dplyr         NA                    NA     
DRR           NA                    NA     
e1071         NA                    NA     
evaluate      NA                    NA     
foreach       NA                    NA     
foreign       NA                    NA     
gdata         NA                    NA     
ggplot2       NA                    NA     
glue          NA                    NA     
gower         NA                    NA     
gplots        NA                    NA     
gridExtra     NA                    NA     
gtable        NA                    NA     
gtools        NA                    NA     
highr         NA                    NA     
ipred         NA                    NA     
iterators     NA                    NA     
kernlab       NA                    NA     
KernSmooth    NA                    NA     
knitr         NA                    NA     
labeling      NA                    NA     
lattice       NA                    NA     
lava          NA                    NA     
lazyeval      NA                    NA     
lubridate     NA                    NA     
magrittr      NA                    NA     
markdown      NA                    NA     
MASS          NA                    NA     
Matrix        NA                    NA     
mgcv          NA                    NA     
mime          NA                    NA     
ModelMetrics  NA                    NA     
munsell       NA                    NA     
nlme          NA                    NA     
numDeriv      NA                    NA     
pbapply       NA                    NA     
pkgconfig     NA                    NA     
plogr         NA                    NA     
              MD5sum NeedsCompilation Built  
anim.plots    NA     "no"             "3.4.1"
animation     NA     "no"             "3.4.1"
assertthat    NA     "no"             "3.4.1"
BH            NA     "no"             "3.4.1"
bindr         NA     "no"             "3.4.1"
bindrcpp      NA     "yes"            "3.4.1"
bitops        NA     "yes"            "3.4.1"
boot          NA     "no"             "3.4.1"
Boruta        NA     "no"             "3.4.1"
caret         NA     "yes"            "3.4.1"
caretEnsemble NA     "no"             "3.4.1"
caTools       NA     "yes"            "3.4.1"
class         NA     "yes"            "3.4.1"
cluster       NA     "yes"            "3.4.1"
codetools     NA     "no"             "3.4.1"
colorspace    NA     "yes"            "3.4.1"
curl          NA     "yes"            "3.4.1"
CVST          NA     "no"             "3.4.1"
data.table    NA     "yes"            "3.4.1"
ddalpha       NA     "yes"            "3.4.1"
DEoptimR      NA     "no"             "3.4.1"
dichromat     NA     NA               "3.4.1"
digest        NA     "yes"            "3.4.1"
dimRed        NA     "yes"            "3.4.1"
dplyr         NA     "yes"            "3.4.1"
DRR           NA     "no"             "3.4.1"
e1071         NA     "yes"            "3.4.1"
evaluate      NA     "no"             "3.4.1"
foreach       NA     "no"             "3.4.1"
foreign       NA     "yes"            "3.4.1"
gdata         NA     "no"             "3.4.1"
ggplot2       NA     "no"             "3.4.1"
glue          NA     "yes"            "3.4.1"
gower         NA     "yes"            "3.4.1"
gplots        NA     "no"             "3.4.1"
gridExtra     NA     "no"             "3.4.1"
gtable        NA     "no"             "3.4.1"
gtools        NA     "yes"            "3.4.1"
highr         NA     "no"             "3.4.1"
ipred         NA     "yes"            "3.4.1"
iterators     NA     "no"             "3.4.1"
kernlab       NA     "yes"            "3.4.1"
KernSmooth    NA     "yes"            "3.4.1"
knitr         NA     "no"             "3.4.1"
labeling      NA     "no"             "3.4.1"
lattice       NA     "yes"            "3.4.1"
lava          NA     "no"             "3.4.1"
lazyeval      NA     "yes"            "3.4.1"
lubridate     NA     "yes"            "3.4.1"
magrittr      NA     "no"             "3.4.1"
markdown      NA     "yes"            "3.4.1"
MASS          NA     "yes"            "3.4.1"
Matrix        NA     "yes"            "3.4.1"
mgcv          NA     "yes"            "3.4.1"
mime          NA     "yes"            "3.4.1"
ModelMetrics  NA     "yes"            "3.4.1"
munsell       NA     "no"             "3.4.1"
nlme          NA     "yes"            "3.4.1"
numDeriv      NA     "no"             "3.4.1"
pbapply       NA     "no"             "3.4.1"
pkgconfig     NA     "no"             "3.4.1"
plogr         NA     "no"             "3.4.1"
 [ reached getOption("max.print") -- omitted 61 rows ]

2017년 11월 6일 월요일

IBM POK Benchmark Center에서 LSF 이용하여 ResNet cifar10 training 수행하기

먼저 우리가 수행할 queue 확인하시고 (여기서는 s822lc_p100nvme 입니다)

b7p286za@p10login1:/gpfs/gpfs_gl4_16mb/b7p286za/models/official/resnet$ bqueues
QUEUE_NAME      PRIO STATUS          MAX JL/U JL/P JL/H NJOBS  PEND   RUN  SUSP
b7p268           30  Open:Active       -    -    -    -     0     0     0     0
pmr              30  Open:Active       -    -    -    -     0     0     0     0
test-pmr         30  Open:Active       -    -    -    -     0     0     0     0
test-redhat      30  Open:Active       -    -    -    -     0     0     0     0
s822lc_p100_k80  30  Closed:Inact      -    -    -    -     0     0     0     0
822normal        30  Open:Active       -    -    -    -     0     0     0     0
s822lc_p100      30  Open:Active       -    -    -    - 22901 20021  2880     0
b7s004           30  Open:Active       -    -    -    -     0     0     0     0
coral_power9     30  Open:Active       -    -    -    -     0     0     0     0
s822lc_p100nvme  30  Open:Active       -    -    -    -     3     0     3     0
normal           30  Open:Active       -    -    -    -     0     0     0     0
s822lc_k80       30  Closed:Inact      -    -    -    -     0     0     0     0


거기에 bsub 명령어 이용하여 gpu 1개 이상인 node로 job을 submit 합니다.

b7p286za@p10login1:/gpfs/gpfs_gl4_16mb/b7p286za/models/official/resnet$ bsub -R "select[ngpus>0] rusage[ngpus_excl_p=1]" -x -q s822lc_p100nvme PYTHONPATH=/gpfs/gpfs_gl4_16mb/b7p286za/anaconda3/lib/python3.6/site-packages time /gpfs/gpfs_gl4_16mb/b7p286za/anaconda3/bin/python /gpfs/gpfs_gl4_16mb/b7p286za/models/official/resnet/cifar10_main.py
Job <158267> is submitted to queue <s822lc_p100nvme>.


여기서 -x option은 exclusive, 즉 GPU를 1장만 쓰더라도 전체 node를 exclusive로 쓰겠다는 option입니다.   Poughkeepsie 센터 운영자들은 사용자들이 이 -x 옵션을 쓰는 것을 관리 편의성 때문에 더 선호한다고 합니다.

Job이 성공적으로 잘 수행 중인지, 어디서 수행 중인지는 bhist 명령으로 확인합니다.

b7p286za@p10login1:/gpfs/gpfs_gl4_16mb/b7p286za/models/official/resnet$ bhist -l 158267
Job <158267>, User <b7p286za>, Project <default>, Command <PYTHONPATH=/gpfs/gpf
                     s_gl4_16mb/b7p286za/anaconda3/lib/python3.6/site-packages
                     time /gpfs/gpfs_gl4_16mb/b7p286za/anaconda3/bin/python /gp
                     fs/gpfs_gl4_16mb/b7p286za/models/official/resnet/cifar10_m
                     ain.py>
Mon Nov  6 01:10:45: Submitted from host <p10login1>, to Queue <s822lc_p100nvme
                     >, CWD </gpfs/gpfs_gl4_16mb/b7p286za/models/official/resne
                     t>, Requested Resources <select[ngpus>0] rusage[ngpus_excl
                     _p=1]>;
Mon Nov  6 01:10:46: Dispatched 1 Task(s) on Host(s) <p10a113>, Allocated 1 Slo
                     t(s) on Host(s) <p10a113>, Effective RES_REQ <select[(ngpu
                     s>0) && (type == local)] order[r15s:pg] rusage[ngpus_excl_
                     p=1.00] >;
Mon Nov  6 01:10:46: Starting (Pid 157797);
Mon Nov  6 01:10:53: Running with execution home </u/b7p286za>, Execution CWD <
                     /gpfs/gpfs_gl4_16mb/b7p286za/models/official/resnet>, Exec
                     ution Pid <157797>;
Mon Nov  6 01:10:53: External Message "p10a113:gpus=1;" was posted from "b7p286
                     za" to message box 0;

Summary of time in seconds spent in various states by  Mon Nov  6 01:11:19
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  1        0        33       0        0        0        34

2017년 11월 1일 수요일

caffe2, tensorflow 1.3, pytorch가 설치된 docker image 만들기

docker hub에서 제공되는 nvidia/cuda-ppc64le 이미지를 이용하여, 거기에 이것저것 원하는 package를 설치하고 docker commit 명령을 통해 새로운 이미지를 만드는 방법을 보시겠습니다.

먼저 parent ubuntu OS에서 필요한 file들을 아래처럼 docker라는 directory에 모아둡니다.

root@firestone:~/docker# ls -l
total 2369580
-rwxr-xr-x  1 root root  284629257 Oct 31 22:27 Anaconda2-4.4.0.1-Linux-ppc64le.sh
-rwxr-xr-x  1 root root  299425582 Oct 31 22:28 Anaconda3-4.4.0.1-Linux-ppc64le.sh
-rw-r--r--  1 root root 1321330418 Oct 31 22:35 cuda-repo-ubuntu1604-8-0-local-ga2v2_8.0.61-1_ppc64el.deb
-rwxr-xr-x  1 root root       8788 Oct 31 21:40 debootstrap.sh
-rw-r--r--  1 root root   68444212 Oct 31 22:35 libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb
-rw-r--r--  1 root root   59820704 Oct 31 22:35 libcudnn6-dev_6.0.21-1+cuda8.0_ppc64el.deb
-rw-r--r--  1 root root    6575300 Oct 31 22:35 libcudnn6-doc_6.0.21-1+cuda8.0_ppc64el.deb
-rw-r--r--  1 root root  386170568 Oct 31 22:36 mldl-repo-local_4.0.0_ppc64el.deb
drwxr-xr-x 21 root root       4096 Oct 31 21:55 ubuntu


이미 nvidia/cuda-ppc64le 이미지는 docker pull 명령으로 당겨왔습니다.

root@firestone:~/docker# docker images | grep nvidia
nvidia-docker                                       build                            405ee913a07e        About an hour ago   1.02GB
nvidia/cuda-ppc64le                                 8.0-cudnn6-runtime-ubuntu16.04   bf28cd22ff84        6 weeks ago         974MB
nvidia/cuda-ppc64le                                 latest                           9b0a21e35c66        6 weeks ago         1.72GB


이제 nvidia/cuda-ppc64le:latest를 interactive mode로 구동합니다.  이때 docker directory를 /docker라는 이름으로 마운트합니다.

root@firestone:~/docker# docker run -ti -v ~/docker:/docker nvidia/cuda-ppc64le:latest bash

이제 nvidia/cuda-ppc64le:latest 안에 들어왔습니다.  /docker로 가서 동일한 file들이 보이는지 확인합니다.

root@deeed8ce922f:/# cd /docker
root@deeed8ce922f:/docker# ls
Anaconda2-4.4.0.1-Linux-ppc64le.sh                         libcudnn6-doc_6.0.21-1+cuda8.0_ppc64el.deb
Anaconda3-4.4.0.1-Linux-ppc64le.sh                         libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb
cuda-repo-ubuntu1604-8-0-local-ga2v2_8.0.61-1_ppc64el.deb  mldl-repo-local_4.0.0_ppc64el.deb
debootstrap.sh                                             ubuntu
libcudnn6-dev_6.0.21-1+cuda8.0_ppc64el.deb


이제 libcudnn6을 먼저 설치합니다.  아울러 NCCL 및 bazel 등을 쓸 수도 있으니 PowerAI 4.0 (mldl-repo-local_4.0.0_ppc64el.deb)의 local repo도 설치합니다.

root@deeed8ce922f:/docker# dpkg -i libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb libcudnn6-dev_6.0.21-1+cuda8.0_ppc64el.deb mldl-repo-local_4.0.0_ppc64el.deb

root@deeed8ce922f:/docker# apt-get update


이제 cuda와 nccl, openblas 등을 설치합니다.

root@deeed8ce922f:/docker# apt-get install cuda

root@deeed8ce922f:/docker# apt-get install -y libnccl-dev libnccl1 python-ncclient bazel libopenblas-dev libopenblas libopenblas-base


이번엔 다른 ssh 세션에서, parent OS에서 docker ps 명령어로 현재 우리가 쓰고 있는 container ID를 확인합니다.

root@firestone:~# docker ps | grep -v k8s
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS               NAMES
deeed8ce922f        nvidia/cuda-ppc64le:latest   "bash"                   About an hour ago   Up About an hour                        gracious_bhaskara


저 container ID에 대해 docker commit 명령을 다음과 같이 날립니다.

root@firestone:~# docker commit deeed8ce922f bsyu/libcudnn6-ppc64le:xenial

이제 새로운 docker image가 생성된 것을 볼 수 있습니다.

root@firestone:~# docker images | grep -v ibm
REPOSITORY                                          TAG                              IMAGE ID            CREATED             SIZE
bsyu/libcudnn6-ppc64le                              xenial                           6d621d9d446b        48 seconds ago      7.52GB
nvidia-docker                                       build                            405ee913a07e        2 hours ago         1.02GB
nvidia/cuda-ppc64le                                 8.0-cudnn6-runtime-ubuntu16.04   bf28cd22ff84        6 weeks ago         974MB
nvidia/cuda-ppc64le                                 latest                           9b0a21e35c66        6 weeks ago         1.72GB
ppc64le/golang                                      1.6.3                            6a579d02d32f        14 months ago       705MB


적절히 tagging한 뒤, docker에 login하여 docker hub으로 push 해둡니다.

root@firestone:~# docker tag bsyu/libcudnn6-ppc64le:xenial bsyu/libcudnn6-ppc64le:latest

root@firestone:~# docker login -u bsyu
Password:
Login Succeeded

root@firestone:~# docker push bsyu/libcudnn6-ppc64le:xenial
The push refers to a repository [docker.io/bsyu/libcudnn6-ppc64le]
de3b55a17936: Pushed
9eb05620c635: Mounted from nvidia/cuda-ppc64le
688827f0a03b: Mounted from nvidia/cuda-ppc64le
a36322f4fa68: Mounted from nvidia/cuda-ppc64le
6665818dfb83: Mounted from nvidia/cuda-ppc64le
4cad4acd0601: Mounted from nvidia/cuda-ppc64le
f12b406a6a23: Mounted from nvidia/cuda-ppc64le
bb179c8bb840: Mounted from nvidia/cuda-ppc64le
cd51df595e0c: Mounted from nvidia/cuda-ppc64le
4a7a95d650cf: Mounted from nvidia/cuda-ppc64le
22c3301fbf0b: Mounted from nvidia/cuda-ppc64le
xenial: digest: sha256:3993ac50b857979694cdc41cf12d672cc078583f1babb79f6c25e0688ed603ed size: 2621


이제 여기에 추가로 caffe2를 설치합니다.  이전 포스팅(http://hwengineer.blogspot.kr/2017/10/minsky-caffe2-jupyter-notebook-mnist.html)에서 build 해두었던 /opt/caffe2 directory를 통째로 tar로 말아두었던 것을 여기에 풀겠습니다.


root@deeed8ce922f:/docker# ls
Anaconda2-4.4.0.1-Linux-ppc64le.sh                         libcudnn6-doc_6.0.21-1+cuda8.0_ppc64el.deb
Anaconda3-4.4.0.1-Linux-ppc64le.sh                         libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb
caffe2.tgz                                                 mldl-repo-local_4.0.0_ppc64el.deb
cuda-repo-ubuntu1604-8-0-local-ga2v2_8.0.61-1_ppc64el.deb  site-packages.tgz
debootstrap.sh                                             ubuntu
libcudnn6-dev_6.0.21-1+cuda8.0_ppc64el.deb

root@deeed8ce922f:/docker# cd /opt
root@deeed8ce922f:/opt# tar -zxf /docker/caffe2.tgz

root@deeed8ce922f:/opt# vi ~/.bashrc
...
export LD_LIBRARY_PATH=/opt/DL/nccl/lib:/opt/DL/openblas/lib:/usr/local/cuda-8.0/lib6:/usr/lib:/usr/local/lib:/opt/caffe2/lib:/usr/lib/powerpc64le-linux-gnu
export PATH=/opt/anaconda2/bin:/opt/caffe2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PYTHONPATH=/opt/caffe2

caffe2가 정상 작동하기 위해 필요한 package들을 추가 설치합니다.

root@deeed8ce922f:/opt# conda install protobuf future

root@deeed8ce922f:/opt# apt-get install libprotobuf-dev python-protobuf libgoogle-glog-dev libopenmpi-dev liblmdb-dev python-lmdb libleveldb-dev python-leveldb libopencv-core-dev libopencv-gpu-dev python-opencv libopencv-highgui-dev libopencv-dev


이제 다시 parent OS에서 다른 이름으로 docker commit 합니다.

root@firestone:~# docker commit deeed8ce922f bsyu/caffe2-ppc64le-xenial:v0.1


이제 GPU를 사용하기 위해 nvidia-docker로 구동해봅니다.   그러자면 (혹시 아직 안 하셨다면) 먼저 nvidia-docker-plugin을 background로 구동해야 합니다.

root@firestone:~# nohup nvidia-docker-plugin &

root@firestone:~# nvidia-docker run -ti --rm -v ~/docker:/docker bsyu/caffe2-ppc64le-xenial:v0.1 bash


bsyu/caffe2-ppc64le-xenial:v0.1 컨테이너에서 caffe2가 성공적으로 import 되는 것을 확인합니다.

root@0e58f6f69c44:/# python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
Success


이 이미지를 이용하여 또 tensorflow 1.3 및 pytorch 0.2.0이 들어간 docker image도 만듭니다.

root@firestone:~# docker run -ti --rm -v ~/docker:/docker bsyu/caffe2-ppc64le-xenial:v0.1 bash

root@8cfeaf93f28b:/# cd /opt
root@8cfeaf93f28b:/opt# ls
DL  anaconda2  anaconda3  caffe2
root@8cfeaf93f28b:/opt# rm -rf caffe2

root@8cfeaf93f28b:/opt# vi ~/.bashrc
...
export LD_LIBRARY_PATH=/opt/DL/nccl/lib:/opt/DL/openblas/lib:/usr/local/cuda-8.0/lib6:/usr/lib:/usr/local/lib:/usr/lib/powerpc64le-linux-gnu
export PATH=/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PYTHONPATH=/opt/anaconda3/lib/python3.6/site-packages


root@8cfeaf93f28b:~# apt-get install libcupti-dev openjdk-8-jdk openjdk-8-jdk-headless git

root@8cfeaf93f28b:~# conda install bazel numpy

root@8cfeaf93f28b:~# git clone --recursive https://github.com/tensorflow/tensorflow.git

root@8cfeaf93f28b:~# cd tensorflow/
root@8cfeaf93f28b:~/tensorflow# git checkout r1.3

root@8cfeaf93f28b:~/tensorflow# ./configure

root@8cfeaf93f28b:~/tensorflow# bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

root@8cfeaf93f28b:~/tensorflow# bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

root@8cfeaf93f28b:~/tensorflow# pip install /tmp/tensorflow_pkg/tensorflow-1.3.1-cp36-cp36m-linux_ppc64le.whl

root@8cfeaf93f28b:~/tensorflow# conda list | grep tensor
tensorflow                1.3.1                     <pip>
tensorflow-tensorboard    0.1.8                     <pip>


이제 tensorflow 1.3이 설치되었으므로 이를 docker commit으로 저장합니다.

root@firestone:~# docker ps | grep -v k8s
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS               NAMES
8cfeaf93f28b        bsyu/caffe2-ppc64le-xenial:v0.1   "bash"                   2 hours ago         Up 2 hours                              vigilant_ptolemy

root@firestone:~# docker commit 8cfeaf93f28b bsyu/tf1.3-caffe2-ppc64le-xenial:v0.1


이 이미지에 다시 pytorch를 설치합니다.

root@8cfeaf93f28b:~# git clone --recursive https://github.com/pytorch/pytorch.git

root@8cfeaf93f28b:~# cd /pytorch

root@8cfeaf93f28b:~/pytorch# export CMAKE_PREFIX_PATH=/opt/pytorch

root@8cfeaf93f28b:~/pytorch# conda install numpy pyyaml setuptools cmake cffi openblas

root@8cfeaf93f28b:~/pytorch# python setup.py install

root@8cfeaf93f28b:~# python
Python 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 15:31:35)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import torch
>>>

이제 최종적으로 bsyu/pytorch-tf1.3-caffe2-ppc64le-xenial:v0.1 라는 이미지를 commit 합니다.

root@firestone:~# docker commit 8cfeaf93f28b bsyu/pytorch-tf1.3-caffe2-ppc64le-xenial:v0.1

root@firestone:~# docker push bsyu/pytorch-tf1.3-caffe2-ppc64le-xenial:v0.1

2017년 10월 30일 월요일

ppc64le에서의 nvidia-docker의 설치 (2017.10)

전에 nvidia-docker를 ppc64le에서 build하는 방법을 올린 적(http://hwengineer.blogspot.kr/2017/02/minsky-ubuntu-1604-xenial-ppc64le.html)이 있습니다.   그 사이에 설치 방법이 업데이트가 된 것이 있어서, 새로 올립니다.

이 URL(https://developer.ibm.com/linuxonpower/docker-on-power)에 나온 가이드대로, 먼저 docker를 설치합니다.

u0017649@sys-89698:~$ sudo vi /etc/apt/sources.list.d/xenial-docker.list
deb http://ftp.unicamp.br/pub/ppc64el/ubuntu/16_04/docker-17.06.0-ce-ppc64el/ xenial main

u0017649@sys-89698:~$ sudo apt-get update

u0017649@sys-89698:~$ sudo apt-get install docker-ce

그 뒤에 아래와 같이 하시면 됩니다.

u0017649@sys-89698:~$ git clone https://github.com/NVIDIA/nvidia-docker.git

u0017649@sys-89698:~$ cd nvidia-docker/

u0017649@sys-89698:~/nvidia-docker$ sudo make
...
Step 21/22 : ENV VERSION $PKG_VERS
 ---> Using cache
 ---> 39d92843179c
Step 22/22 : CMD go install -v -ldflags="-s -X main.Version=$VERSION" ./...
 ---> Using cache
 ---> a66fd805e845
Successfully built a66fd805e845
Successfully tagged nvidia-docker:build
github.com/NVIDIA/nvidia-docker/src/nvidia-docker-plugin
github.com/NVIDIA/nvidia-docker/src/nvidia-docker


u0017649@sys-89698:~/nvidia-docker$ sudo make install
...
Step 21/22 : ENV VERSION $PKG_VERS
 ---> Using cache
 ---> 39d92843179c
Step 22/22 : CMD go install -v -ldflags="-s -X main.Version=$VERSION" ./...
 ---> Using cache
 ---> a66fd805e845
Successfully built a66fd805e845
Successfully tagged nvidia-docker:build
github.com/NVIDIA/nvidia-docker/src/nvidia-docker
github.com/NVIDIA/nvidia-docker/src/nvidia-docker-plugin
install -D -m 755 -t /usr/local/bin /home/u0017649/nvidia-docker/bin/nvidia-docker
install -D -m 755 -t /usr/local/bin /home/u0017649/nvidia-docker/bin/nvidia-docker-plugin

u0017649@sys-89698:~$ which nvidia-docker
/usr/local/bin/nvidia-docker

그리고 이렇게 설치된 nvidia-docker에서는 nvidia-docker-plugin을 수동으로 살려줘야 합니다.  매번 그러기는 귀찮으니, 아예 /etc/rc.local에 아래와 같이 1줄 넣어주는 것을 권고합니다.  그러면 부팅 때마다 nvidia-docker-plugin이 백그라운드로 떠있게 됩니다.

/usr/local/bin/nvidia-docker-plugin &

그러난 뒤에, 아래와 같이 제가 미리 build 해둔 tensorflow 1.3과 python3용 Anaconda가 설치된 ppc64le용 docker image를 pull 하시면 됩니다.

root@firestone:/home# docker pull bsyu/tf1.3-ppc64le:v0.1
v0.3: Pulling from bsyu/tf1.3-ppc64le
0ad9ca03f1b2: Already exists
7d2491df9494: Already exists
9a961cbb08c0: Already exists
9f38c9e24bdd: Already exists
36070ab6f935: Already exists
dd84cc8c7847: Already exists
4317eeb0f4b7: Already exists
13f482d825bc: Already exists
d221c8d6a86c: Already exists
994d0d1ac151: Already exists
c736e0aba22f: Already exists
e7b4f7096c8f: Already exists
a0aaaa391ef4: Downloading  3.165MB/38.83MB
3c8d454a2390: Download complete
9bdf7a145ee5: Downloading  2.671MB/120.4MB

이왕 하실 때 기타 아래 것들도 받아두시면 해로울 건 없겠습니다.

# docker pull bsyu/cudnn6-conda2-ppc64le:v0.1  (python 2.7의 anaconda image)
# docker pull bsyu/cudnn6-conda3-ppc64le:v0.1  (python 3.6의 anaconda image)


-------- 이하는 그냥 실습 옵션입니다.

이제 여기서 ppc64le/ubuntu:latest를 이용하여 libcudnn 6.0와 anaconda2/3 등이 설치된 docker image를 빌드해보겠습니다.

u0017649@sys-89830:~/docker$ ls
Anaconda2-4.4.0.1-Linux-ppc64le.sh
Anaconda3-4.4.0.1-Linux-ppc64le.sh
cuda-repo-ubuntu1604-8-0-local-cublas-performance-update_8.0.61-1_ppc64el-deb
cuda-repo-ubuntu1604-8-0-local-ga2v2_8.0.61-1_ppc64el-deb
dockerfile.cudnn6
libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb
libcudnn6-dev_6.0.21-1+cuda8.0_ppc64el.deb
mldl-repo-local_4.0.0_ppc64el.deb

관련 file들을 위와 같이 ~/docker 디렉토리 속에 모아놓은 뒤, 아래와 같이 dockerfile을 구성합니다.

u0017649@sys-89830:~/docker$ vi dockerfile.cudnn6
FROM ppc64le/ubuntu:latest

ENV CUDNN_VERSION 6.0.21
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"

RUN mkdir /tmp/temp
COPY *deb /tmp/temp/
COPY *.sh /tmp/temp/
RUN dpkg -i /tmp/temp/cuda-repo-ubuntu1604-8-0-local-ga2v2_8.0.61-1_ppc64el-deb && \
   dpkg -i /tmp/temp/cuda-repo-ubuntu1604-8-0-local-cublas-performance-update_8.0.61-1_ppc64el-deb && \
   apt-get update && apt-get install -y --no-install-recommends initramfs-tools && \
   apt-get install -y cuda && \
   dpkg -i /tmp/temp/libcudnn* && \
   dpkg -i /tmp/temp/mldl-repo-local_4.0.0_ppc64el.deb && \
   /tmp/temp/Anaconda3-4.4.0.1-Linux-ppc64le.sh -b -p /opt/anaconda3 && \
   /tmp/temp/Anaconda2-4.4.0.1-Linux-ppc64le.sh -b -p /opt/anaconda2 && \
   apt-get install -y libnccl-dev libnccl1 python-ncclient bazel libopenblas-dev libopenblas libopenblas-base && \
   apt-get remove -y mldl-repo-local && \
   apt-get remove -y cuda-repo-ubuntu1604-8-0-local-ga2v2 cuda-repo-ubuntu1604-8-0-local-cublas-performance-update && \
   ldconfig && \
   rm -rf /tmp/temp && \
   rm -rf /var/lib/apt/lists/*
ENV LD_LIBRARY_PATH="/opt/DL/nccl/lib:/opt/DL/openblas/lib:/usr/local/cuda-8.0/lib6:/usr/lib:/usr/local/lib:/opt/caffe2/lib:/usr/lib/powerpc64le-linux-gnu"
ENV PATH="/opt/anaconda2/bin:/opt/caffe2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

이제 이걸 아래와 같이 build 하면 됩니다.

u0017649@sys-89830:~/docker$ sudo docker build -t bsyu/cudnn6_v0.1:ppc64le-xenial -f dockerfile.cudnn6 .

저는 한창 진행 중에 아래와 같이 disk 공간 부족으로 error가 나네요.  PDP(Power Development Platform) cloud는 disk 공간이 너무 작은 것이 탈입니다...

Preparing to unpack .../libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb ...
Unpacking libcudnn6 (6.0.21-1+cuda8.0) ...
dpkg: error processing archive /tmp/temp/libcudnn6_6.0.21-1+cuda8.0_ppc64el.deb (--install):
 cannot copy extracted data for './usr/lib/powerpc64le-linux-gnu/libcudnn.so.6.0.21' to '/usr/lib/powerpc64le-linux-gnu/libcudnn.so.6.0.21.dpkg-new': failed to write (No space left on device)
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)

2017년 10월 27일 금요일

caffe-ibm의 LMS 기능에 대한 설명

전에 올린 DDL 관련 포스팅(https://hwengineer.blogspot.kr/2017/10/caffe-ddl-alexnet-training.html)에서, LMS(large model support) 기능을 믿고 batch_size를 화끈하게 2048이나 4096으로 올리면 어떤가라는 질문이 있을 수 있습니다.  결론부터 말씀드리면 LMS를 쓴다고 해도 batch_size를 무한정 키울 수는 없습니다.

먼저 저 포스팅에 나와 있듯이, LMS 기능은 '기존 GPU memory 한계 때문에 돌릴 수 없었던 큰 모델도 돌릴 수 있게 해주는 기능'이지, 이 때문에 반드시 더 빠른 성능을 낼 수 있는 것은 아닙니다.  아무리 NVLink를 통해 가져온다고 해도, host server memory가 GPU memory보다는 느리니까요.

그와는 별도로, LMS도 무한정 host memory를 쓸 수는 없습니다.  Lab에서 들은 이야기입니다만, LMS를 쓴다고 해도 아래 정보들은 반드시 GPU memory 상에 올라가야 한다고 합니다.

- input tensor
- output tensor
- weight
- gradient (training인 경우)

그리고 이 정보들이 차지하는 memory의 양은 batch_size가 늘어날 수록 함께 늘어나는데, 그로 인해 결국 한계가 있습니다.  LMS의 핵심은, deep learning에서 layer별로 training을 할 때, 당장 처리하고 있는 layer는 GPU memory 위에 두더라도, 이미 처리했거나 나중에 처리할 layer들은 host memory에 저장할 수 있다는 것입니다.  따라서, LMS로 처리가능한 최대 neural network 크기는 그 neural network에서 가장 큰 layer의 크기에 달려 있다고 할 수 있습니다.



가령 전에 테스트했던, Alexnet의 deploy.prototxt 이용해서 'caffe time'을 수행할 때 보면 아래와 같이 data, conv1, relu1 등 총 24개의 layer가 만들어집니다.

$ grep "Creating Layer" caffe_time.log

I1025 16:37:01.848961 29514 net.cpp:90] Creating Layer data
I1025 16:37:01.867213 29514 net.cpp:90] Creating Layer conv1

I1025 16:37:03.477823 29514 net.cpp:90] Creating Layer fc8
I1025 16:37:03.481210 29514 net.cpp:90] Creating Layer prob

그리고 각 layer마다 다음과 같이 Top shape가 정해지면서 "Memory required for data"가 연산됩니다.  그리고 그 값은 처음 layer에서는 작아도 나중에는 매우 커지지요.


I1025 16:37:01.867137 29514 net.cpp:135] Top shape: 10 3 1600 1200 (57600000)
I1025 16:37:01.867183 29514 net.cpp:143] Memory required for data: 230400000

I1025 16:37:02.231456 29514 net.cpp:135] Top shape: 10 96 398 298 (113859840)
I1025 16:37:02.231468 29514 net.cpp:143] Memory required for data: 685839360

I1025 16:37:02.246103 29514 net.cpp:135] Top shape: 10 256 49 37 (4641280)
I1025 16:37:02.246112 29514 net.cpp:143] Memory required for data: 3315185920


이런 특성들로 인해, wide한 (layer별 메모리 필요량이 많은) neural network보다는 deep한 (layer 개수가 많은) neural network이 LMS의 잇점을 훨씬 더 잘 살릴 수 있습니다.



LMS의 진정한 장점을 정리하면 아래와 같습니다.

1) width로는 10-30배 정도 더 큰 모델 사용 가능
2) depth로는 무한대의 큰 모델을 사용 가능 

특성상 layer들이 많은 RNN에서 LMS가 특히 유용하게 쓰일 수 있다고 합니다.   그리고 요즘 신경망 발전 방향이 wide해지는 방향이 아니라 점점 deep해지는 방향이라고 합니다.  가령 몇년 전에 나온 Alexnet 같은 경우 이론상 7개 layer라고 하는데, 그로부터 4년 뒤에 나온 ResNet 같은 경우 1000개 layer라고 하지요.  LMS의 적용 범위는 점점 넓어지고 있다고 할 수 있습니다. 

caffe DDL을 이용한 Alexnet training

지난 9월 포스팅(http://hwengineer.blogspot.kr/2017/09/ibm-powerai-40-caffe-distributed-deep.html)에서 PowerAI에 포함된 DDL(Distributed Deep Learning), 즉 MPI를 이용한 분산처리 기능에 대해 간단히 설명드린 바 있습니다.  이번에는 그것으로 ILSVRC2012의 128만장 image dataset을 caffe alexnet으로 training 해보겠습니다.

제가 잠깐 빌릴 수 있는 Minsky 서버가 딱 1대 뿐이라, 원래 여러대의 Minsky 서버를 묶어서 하나의 model을 train시킬 수 있지만 여기서는 1대의 서버에서 caffe DDL을 수행해보겠습니다.  잠깐, 1대라고요 ?  1대에서 MPI 분산처리가 의미가 있나요 ?

예, 없지는 않습니다.  Multi-GPU를 이용한 training을 할 때 일반 caffe와 caffe DDL의 차이는 multi-thread냐, multi-process냐의 차이입니다.  좀더 쉽게 말해, 일반 caffe에서는 하나의 caffe process가 P2P를 통해 여러개의 GPU를 사용합니다.  그에 비해, caffe DDL에서는 GPU당 1개씩 별도의 caffe process가 떠서, 서로간에 MPI를 이용한 통신을 하며 여러개의 GPU를 사용합니다.

이를 그림으로 표현하면 아래와 같습니다.



실제로, 일반 caffe를 사용할 경우 nvidia-smi로 관찰해보면 다음과 같이 caffe의 PID가 모두 같지만, caffe DDL에서는 각 GPU를 사용하는 caffe PID가 서로 다릅니다.

일반 caffe :

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     30681    C   caffe                                        15497MiB |
|    1     30681    C   caffe                                        14589MiB |
|    2     30681    C   caffe                                        14589MiB |
|    3     30681    C   caffe                                        14589MiB |
+-----------------------------------------------------------------------------+

caffe DDL :

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     31227    C   caffe                                        15741MiB |
|    1     31228    C   caffe                                        14837MiB |
|    2     31229    C   caffe                                        14837MiB |
|    3     31230    C   caffe                                        14837MiB |
+-----------------------------------------------------------------------------+

자, 대략 차이를 이해하셨으면, alexnet training을 한번은 일반 caffe로, 또 한번은 caffe DDL로 training해보시지요.  물론 모두 같은 Minsky 서버, 즉 4-GPU 시스템 1대를 써서 테스트한 것입니다.  각각의 성능 측정은 128만장을 2-epochs, 즉 2회 반복 training할 때 걸린 시간으로 측정하겠습니다.

일반 caffe :

test@ubuntu:/nvme$ caffe train --solver=models/bvlc_alexnet/solver.prototxt -gpu all

caffe DDL :

test@ubuntu:/nvme$ mpirun -x PATH -x LD_LIBRARY_PATH -n 4 -rf 4x1x1.rf caffe train --solver=models/bvlc_alexnet/solver.prototxt -gpu 0 -ddl "-mode n:4x1x1 -dev_sync 1"

지난번에 잠깐 설명드린 것을 반복하자면 이렇습니다.

- mpirun은 여러대의 서버 노드에 동일한 명령을 동일한 환경변수 (-x 옵션)을 써서 수행해주는 병렬환경 명령어입니다.
- 4x1x1.rf라는 이름의 파일은 rank file입니다.  이 속에 병렬 서버 환경의 toplogy가 들어있습니다.
- -n 4라는 것은 MPI client의 총 숫자이며, 쉽게 말해 training에 이용하려는 GPU의 갯수입니다.
- -gpu 0에서, 왜 4개가 아니라 gpu 0이라고 1개로 지정했는지 의아하실 수 있는데, MPI 환경에서는 각각의 GPU가 하나의 learner가 됩니다.  따라서 실제 물리적 서버 1대에 GPU가 몇 장 장착되어있든 상관없이 모두 -gpu 0, 즉 GPU는 1개로 지정한 것입니다.
- "-mode b:4x1x1"에서 b라는 것은 가능하면 enhanced NCCL을 이용하라는 뜻입니다.  4x1x1은 4장의 GPU를 가진 서버 1대가 하나의 rack에 들어있다는 뜻입니다.
- dev_sync에서 0은 GPU간 sync를 하지 말라는 것이고, 1은 통신 시작할 때 sync하라는 뜻, 2는 시작할 때와 끝낼 때 각각 sync하라는 뜻입니다.

여기서 사용된 rank file 4x1x1.rf 속의 내용은 아래와 같습니다.

rank 0=minksy           slot=0:0-3
rank 1=minksy           slot=0:4-7
rank 2=minksy           slot=1:0-3
rank 3=minksy           slot=1:4-7

128만장 x 2-epochs를 처리하기 위해서는, solver.prototxt와 train_val.prototxt 속에 표시된 batch_size와 max_iter의 곱이 128만장 x 2 = 256만장이면 됩니다.  batch_size를 조절함에 따라 training 속도가 꽤 달라지는데, 여기서는 256부터 512, 768 순으로 늘려가며 테스트해보겠습니다.



위 표에서 보시다시피, batch_size가 작을 때는 일반 caffe의 성능이 더 빨랐는데, batch_size가 점점 커지면서 caffe DDL의 성능이 점점 더 빨라져서 결국 역전하게 됩니다.  batch_size와 MPI를 이용한 DDL의 성능과의 상관 관계가 있을 것 같기는 한데, 아직 그 이유는 파악을 못 했습니다.  Lab에 문의해봤는데, batch_size와는 무관할 것이라는 답변을 받긴 했습니다.


여기서 batch_size를 1024보다 더 키우면 어떻게 될까요 ?

...
F1025 17:48:43.059572 30265 syncedmem.cpp:651] Check failed: error == cudaSuccess (2 vs. 0)  out of memoryF1025 17:48:43.071281 30285 syncedmem.cpp:651] Check failed: error == cudaSuccess (2 vs. 0)  out of memory
*** Check failure stack trace: ***
    @     0x3fffb645ce0c  google::LogMessage::Fail()
    @     0x3fffb69649cc  caffe::Solver<>::Step()
    @     0x3fffb645f284  google::LogMessage::SendToLog()
...

일반 caffe든 caffe DDL이든 batch_size가 1100만 되어도 이렇게 out-of-memory (OOM) error를 내며 죽어버립니다.  그러니 아쉽게도 더 큰 batch_size에서는 테스트가 안되는 것이지요.

batch_size가 너무 커서 OOM error가 난다면 그걸 또 피해가는 방법이 있습니다.  역시 caffe-ibm에 포함된 LMS(large model support)입니다.   아래와 같이 -lms 옵션을 주면 caffe나 caffe DDL이나 모두 batch_size=1200 정도까지는 무난히 돌릴 수 있습니다.  -lms 800000이라는 것은 800000KB 이상의 memory chunk는 GPU 말고 CPU에 남겨두라는 뜻입니다.   (http://hwengineer.blogspot.kr/2017/09/inference-gpu-sizing-ibm-caffe-large.html 참조)


일반 caffe with LMS :

test@ubuntu:/nvme$ caffe train -lms 800000 --solver=models/bvlc_alexnet/solver.prototxt -gpu all

caffe DDL with LMS :

test@ubuntu:/nvme$ mpirun -x PATH -x LD_LIBRARY_PATH -n 4 -rf 4x1x1.rf caffe train -lms 800000 --solver=models/bvlc_alexnet/solver.prototxt -gpu 0 -ddl "-mode n:4x1x1 -dev_sync 1"


그 결과는 아래와 같습니다.   확실히 batch_size가 커질 수록 일반 caffe보다 caffe DDL의 성능이 더 잘 나옵니다.




궁금해하실 분들을 위해서, caffe DDL을 수행할 경우 나오는 메시지의 앞부분과 뒷부분 일부를 아래에 붙여놓습니다.

--------------------------------------------------------------------------
[[31653,1],2]: A high-performance Open MPI point-to-point messaging module
was unable to find any relevant network interfaces:

Module: OpenFabrics (openib)
  Host: minsky

Another transport will be used instead, although this may result in
lower performance.
--------------------------------------------------------------------------
ubuntu: n0(0) n1(0) n2(0) n3(0) 
I1025 18:59:45.681555 31227 caffe.cpp:151] [MPI:0   ] spreading GPUs per MPI rank
I1025 18:59:45.681725 31227 caffe.cpp:153] [MPI:0   ]    use gpu[0]
I1025 18:59:45.681541 31228 caffe.cpp:151] [MPI:1   ] spreading GPUs per MPI rank
I1025 18:59:45.681725 31228 caffe.cpp:153] [MPI:1   ]    use gpu[1]
I1025 18:59:45.681541 31229 caffe.cpp:151] [MPI:2   ] spreading GPUs per MPI rank
I1025 18:59:45.681726 31229 caffe.cpp:153] [MPI:2   ]    use gpu[2]
I1025 18:59:45.681735 31229 caffe.cpp:283] Using GPUs 2
I1025 18:59:45.681541 31230 caffe.cpp:151] [MPI:3   ] spreading GPUs per MPI rank
I1025 18:59:45.681726 31230 caffe.cpp:153] [MPI:3   ]    use gpu[3]
I1025 18:59:45.681735 31230 caffe.cpp:283] Using GPUs 3
I1025 18:59:45.681735 31227 caffe.cpp:283] Using GPUs 0
I1025 18:59:45.681733 31228 caffe.cpp:283] Using GPUs 1
I1025 18:59:45.683846 31228 caffe.cpp:288] GPU 1: Tesla P100-SXM2-16GB
I1025 18:59:45.683897 31227 caffe.cpp:288] GPU 0: Tesla P100-SXM2-16GB
I1025 18:59:45.683955 31230 caffe.cpp:288] GPU 3: Tesla P100-SXM2-16GB
I1025 18:59:45.684010 31229 caffe.cpp:288] GPU 2: Tesla P100-SXM2-16GB
I1025 18:59:46.056959 31227 caffe.cpp:302] [MPI:0   ]  name = minsky root = 1
I1025 18:59:46.067212 31228 caffe.cpp:302] [MPI:1   ]  name = minsky root = 1
I1025 18:59:46.070734 31230 caffe.cpp:302] [MPI:3   ]  name = minsky root = 1
I1025 18:59:46.071211 31229 caffe.cpp:302] [MPI:2   ]  name = minsky root = 1
I1025 18:59:46.073958 31227 solver.cpp:44] Initializing solver from parameters: 
test_iter: 1000
test_interval: 1000
base_lr: 0.01
display: 500
max_iter: 2500
lr_policy: "step"
gamma: 0.1

...중략...

I1025 19:24:53.536928 31227 solver.cpp:414]     Test net output #0: accuracy = 0.20032
I1025 19:24:53.536965 31227 solver.cpp:414]     Test net output #1: loss = 4.09802 (* 1 = 4.09802 loss)
I1025 19:24:54.180562 31227 solver.cpp:223] Iteration 2000 (1.27922 iter/s, 390.864s/500 iters), loss = 4.18248
I1025 19:24:54.180598 31227 solver.cpp:242]     Train net output #0: loss = 4.18248 (* 1 = 4.18248 loss)
I1025 19:24:54.180613 31227 sgd_solver.cpp:121] Iteration 2000, lr = 0.01
I1025 19:26:57.349701 31256 data_layer.cpp:86] Restarting data prefetching from start.
I1025 19:30:28.547333 31256 data_layer.cpp:86] Restarting data prefetching from start.
I1025 19:30:29.081480 31227 solver.cpp:466] Snapshotting to binary proto file models/bvlc_alexnet/caffe_alexnet_train_iter_2500.caffemodel
I1025 19:30:29.283386 31228 solver.cpp:315] Iteration 2500, loss = 3.91634
I1025 19:30:29.283444 31228 solver.cpp:320] Optimization Done.
I1025 19:30:29.283535 31230 solver.cpp:315] Iteration 2500, loss = 3.9612
I1025 19:30:29.283582 31230 solver.cpp:320] Optimization Done.
I1025 19:30:29.285512 31228 caffe.cpp:357] Optimization Done.
I1025 19:30:29.285521 31228 caffe.cpp:359] [MPI:1   ] MPI_Finalize
I1025 19:30:29.285697 31230 caffe.cpp:357] Optimization Done.
I1025 19:30:29.285706 31230 caffe.cpp:359] [MPI:3   ] MPI_Finalize
I1025 19:30:29.286912 31229 solver.cpp:315] Iteration 2500, loss = 3.90313
I1025 19:30:29.286952 31229 solver.cpp:320] Optimization Done.
I1025 19:30:29.290489 31229 caffe.cpp:357] Optimization Done.
I1025 19:30:29.290498 31229 caffe.cpp:359] [MPI:2   ] MPI_Finalize
I1025 19:30:29.973234 31227 sgd_solver.cpp:356] Snapshotting solver state to binary proto file models/bvlc_alexnet/caffe_alexnet_train_iter_2500.solverstate
I1025 19:30:30.727695 31227 solver.cpp:315] Iteration 2500, loss = 3.89638
I1025 19:30:30.727744 31227 solver.cpp:320] Optimization Done.
I1025 19:30:30.729465 31227 caffe.cpp:357] Optimization Done.
I1025 19:30:30.729475 31227 caffe.cpp:359] [MPI:0   ] MPI_Finalize