zoukankan      html  css  js  c++  java
  • Torch7安装脚本

    1.首先安装一些依赖包

    1  yum -y install gcc-c++ qt-devel qt readline libreadline-java readline-devel git cmake gcc curl

    2.开始安装torch7

      1 #!/bin/sh
      2 
      3 ######################################################################
      4 # Torch install
      5 #
      6 # This script installs Torch7, and a few extra packages
      7 # (penlight, optim, parallel, image).
      8 # 
      9 # The install is done via Luarocks, which enables package
     10 # versions. This is the recommended method to deploy Torch,
     11 # torch-pkg is being deprecated.
     12 #
     13 #    Once this script has been run once, you should be able to run
     14 #    extra luarocks commands, and in particular install new packages:
     15 #    $ luarocks install json
     16 #    $ torch
     17 #    > require 'json'
     18 #
     19 ######################################################################
     20 
     21 # Prefix:
     22 #PREFIX=${PREFIX-/usr/local}
     23 PREFIX=$1
     24 len_prefix=`echo $PREFIX|awk '{print length($0)}'`
     25 if [ $len_prefix -eq 0 ];then
     26     echo -e "33[31;5mPlease input the installation directory..33[0m"
     27 else
     28     echo "Installing Torch into: $PREFIX"
     29 
     30     if [[ `uname` == 'Linux' ]]; then
     31         export CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
     32     fi
     33 
     34     # Build and install Torch7
     35     cd /tmp
     36     git clone https://github.com/torch/luajit-rocks.git
     37     cd luajit-rocks
     38     mkdir build; cd build
     39     git checkout master; git pull
     40     rm -f CMakeCache.txt
     41     cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release
     42     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     43     make
     44     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     45     make install || sudo -E make install
     46     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     47     # check if we are on mac and fix RPATH for local install
     48     path_to_install_name_tool=$(which install_name_tool)
     49     if [ -x "$path_to_install_name_tool" ] 
     50     then
     51        install_name_tool -id ${PREFIX}/lib/libluajit.dylib ${PREFIX}/lib/libluajit.dylib
     52     fi
     53 
     54     # Statuses:
     55     sundown=ok
     56     cwrap=ok
     57     paths=ok
     58     torch=ok
     59     nn=ok
     60     dok=ok
     61     gnuplot=ok
     62     qtlua=ok
     63     qttorch=ok
     64     lfs=ok
     65     penlight=ok
     66     sys=ok
     67     xlua=ok
     68     image=ok
     69     optim=ok
     70     cjson=ok
     71     trepl=ok
     72 
     73     path_to_nvcc=$(which nvcc)
     74     if [ -x "$path_to_nvcc" ]
     75     then  
     76         cutorch=ok
     77         cunn=ok
     78     fi
     79 
     80     # Install base packages:
     81     $PREFIX/bin/luarocks install sundown       ||  sudo -E $PREFIX/bin/luarocks install sundown
     82     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     83     $PREFIX/bin/luarocks install cwrap         ||  sudo -E $PREFIX/bin/luarocks install cwrap  
     84     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     85     $PREFIX/bin/luarocks install paths         ||  sudo -E $PREFIX/bin/luarocks install paths  
     86     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     87     $PREFIX/bin/luarocks install torch         ||  sudo -E $PREFIX/bin/luarocks install torch  
     88     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     89     $PREFIX/bin/luarocks install nn            ||  sudo -E $PREFIX/bin/luarocks install nn     
     90     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     91     $PREFIX/bin/luarocks install dok           ||  sudo -E $PREFIX/bin/luarocks install dok    
     92     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     93     $PREFIX/bin/luarocks install gnuplot       ||  sudo -E $PREFIX/bin/luarocks install gnuplot
     94     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
     95     [ -n "$cutorch" ] && 
     96     ($PREFIX/bin/luarocks install cutorch      ||  sudo -E $PREFIX/bin/luarocks install cutorch        ||   cutorch=failed )
     97     [ -n "$cunn" ] && 
     98     ($PREFIX/bin/luarocks install cunn         ||  sudo -E $PREFIX/bin/luarocks install cunn           ||   cunn=failed )
     99 
    100     $PREFIX/bin/luarocks install qtlua         ||  sudo -E $PREFIX/bin/luarocks install qtlua  
    101     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    102     $PREFIX/bin/luarocks install qttorch       ||  sudo -E $PREFIX/bin/luarocks install qttorch
    103     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    104     $PREFIX/bin/luarocks install luafilesystem ||  sudo -E $PREFIX/bin/luarocks install luafilesystem
    105     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    106     $PREFIX/bin/luarocks install penlight      ||  sudo -E $PREFIX/bin/luarocks install penlight 
    107     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    108     $PREFIX/bin/luarocks install sys           ||  sudo -E $PREFIX/bin/luarocks install sys      
    109     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    110     $PREFIX/bin/luarocks install xlua          ||  sudo -E $PREFIX/bin/luarocks install xlua     
    111     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    112     $PREFIX/bin/luarocks install image         ||  sudo -E $PREFIX/bin/luarocks install image    
    113     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    114     $PREFIX/bin/luarocks install optim         ||  sudo -E $PREFIX/bin/luarocks install optim    
    115     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    116     $PREFIX/bin/luarocks install lua-cjson     ||  sudo -E $PREFIX/bin/luarocks install lua-cjson
    117     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    118     $PREFIX/bin/luarocks install trepl         ||  sudo -E $PREFIX/bin/luarocks install trepl    
    119     RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
    120 
    121     # Done.
    122     echo ""
    123     echo "=> Torch7 has been installed successfully"
    124     echo ""
    125     echo "  + Extra packages have been installed as well:"
    126     echo "     $ luarocks list"
    127     echo ""
    128     echo "  + To install more packages, do:"
    129     echo "     $ luarocks search --all"
    130     echo "     $ luarocks install PKG_NAME"
    131     echo ""
    132     echo "  + Note: on MacOS, it's a good idea to install GCC 5 to enable OpenMP."
    133     echo "     You can do this by with brew"
    134     echo "      $ brew install gcc --without-multilib"
    135     echo "     type the following lines before running the installation script"
    136     echo "      export CC=gcc-5"
    137     echo "      export CXX=g++-5"
    138     echo "     For installing cunn, you will need instead the default AppleClang compiler,"
    139     echo "     which means you should open a new terminal (with unexported CC and CXX) and"
    140     echo "      luarocks install cunn"
    141     echo ""
    142     echo "  + packages installed:"
    143     echo "    - sundown   : " $sundown
    144     echo "    - cwrap     : " $cwrap
    145     echo "    - paths     : " $paths
    146     echo "    - torch     : " $torch
    147     echo "    - nn        : " $nn
    148     echo "    - dok       : " $dok
    149     echo "    - gnuplot   : " $gnuplot
    150     [ -n "$cutorch" ] && echo "    - cutorch   : " $cutorch
    151     [ -n "$cunn" ]    && echo "    - cunn      : " $cunn
    152     echo "    - qtlua     : " $qtlua
    153     echo "    - qttorch   : " $qttorch
    154     echo "    - lfs       : " $lfs
    155     echo "    - penlight  : " $penlight
    156     echo "    - sys       : " $sys
    157     echo "    - xlua      : " $xlua
    158     echo "    - image     : " $image
    159     echo "    - optim     : " $optim
    160     echo "    - cjson     : " $cjson
    161     echo "    - trepl     : " $trepl
    162     echo ""
    163 fi
  • 相关阅读:
    设计模式 --单例模式
    Neor Profile SQL 中文汉化
    office online server 安装部署整合到到C#项目
    C# 线程池
    WinForm版 屏幕截图
    golang-nsq高性能消息队列
    【Go Time】Go语言里的条件语句else、switch
    【Go Time】Go语言常量定义关键字const
    【Go Time】Go定义变量
    【Go Time】Go语言里的空接口
  • 原文地址:https://www.cnblogs.com/zl-py/p/6138434.html
Copyright © 2011-2022 走看看