install torch7 on centos6.5

install torch7 on centos6.5+cuda6.5

  • step1:setting system environment for installing torch and itorch
  • step2:installing torch on centos 
  • step3: installing itorch on centos
  • step4: installing matio
step1:setting system environment for installing torch and itorch
reference website:https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4 

#Run the following command to update the system applications:
yum -y update
##preparing centos for installing torch and itorch

#In order to get the necessary development tools, run the following:
yum groupinstall -y development
#To download some additional packages which are handy:
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel


#Installing Python
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
#if you not have XZlibrary, run the following to install XZ library:
yum install xz-libs

xz -d Python-2.7.6.tar.xz
tar -xvf Python-2.7.6.tar
cd Python-2.7.6
./configure --prefix=/usr/local    
make
make altinstall

#building soft connection to make system default python pointing to python2.7
mv /usr/bin/python /usr/bin/python2.6.6 
ln -s /usr/local/bin/python2.7 /usr/bin/python  

#因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
vi /usr/bin/yum  
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6

##Setting Up Common Python Tools pip and virtualenv
##Before installing pip, we need to get its only external dependency - setuptools.
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python2.7 setup.py install
##Let's download the setup files for pip and have Python (2.7) install it:
curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python2.7 -
pip install virtualenv


##installing ipython:http://ipython.org/install.html  https://ipython.org/ipython-doc/2/install/install.html
pip install jupyter
pip install ipython

step2:installing torch on centos 

##http://pastebin.com/KcbXSxtS#
##https://github.com/torch/distro/issues/16
##https://groups.google.com/forum/embed/?place=forum/torch7#!topic/torch7/KncVVkMScmI


sudo yum install -y epel-release # a lot of things live in EPEL
sudo yum install -y cmake curl readline-devel ncurses-devel \
                                gcc-c++ gcc-gfortran git gnuplot unzip \
                                nodejs npm libjpeg-turbo-devel libpng-devel \
                                ImageMagick GraphicsMagick-devel fftw-devel \
                                sox-devel sox zeromq3-devel \
                                qt-devel qtwebkit-devel sox-plugins-freeworld
sudo yum install -y python-ipython


# Get and build OpenBlas (Torch is much better with a decent Blas)
cd /tmp/
git clone https://github.com/xianyi/OpenBLAS.git -b master
cd OpenBLAS
if [ $(getconf _NPROCESSORS_ONLN) = 1 ]; then
    make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0
else
    make NO_AFFINITY=1 USE_OPENMP=1
fi
RET=$?; 
if [ $RET -ne 0 ]; then
    echo "Error. OpenBLAS could not be compiled";
    exit $RET;
fi
sudo make install
RET=$?; 
if [ $RET -ne 0 ]; then
    echo "Error. OpenBLAS could not be installed";
    exit $RET;
fi


# Prefix:
PREFIX=${PREFIX-/usr/local}
echo "Installing Torch into: $PREFIX"


if [[ `uname` == 'Linux' ]]; then
    export CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
fi


# Build and install Torch7
cd /tmp
git clone https://github.com/torch/luajit-rocks.git
cd luajit-rocks
mkdir build; cd build
git checkout master; git pull
rm -f CMakeCache.txt
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make install || sudo -E make install
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
# check if we are on mac and fix RPATH for local install
path_to_install_name_tool=$(which install_name_tool)
if [ -x "$path_to_install_name_tool" ] 
then
   install_name_tool -id ${PREFIX}/lib/libluajit.dylib ${PREFIX}/lib/libluajit.dylib
fi


# Statuses:
sundown=ok
cwrap=ok
paths=ok
torch=ok
nn=ok
dok=ok
gnuplot=ok
qtlua=ok
qttorch=ok
lfs=ok
penlight=ok
sys=ok
xlua=ok
image=ok
optim=ok
cjson=ok
trepl=ok


path_to_nvcc=$(which nvcc)
if [ -x "$path_to_nvcc" ]
then  
    cutorch=ok
    cunn=ok
fi


# Install base packages:
$PREFIX/bin/luarocks install sundown       ||  sudo -E $PREFIX/bin/luarocks install sundown
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install cwrap         ||  sudo -E $PREFIX/bin/luarocks install cwrap  
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install paths         ||  sudo -E $PREFIX/bin/luarocks install paths  
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install torch         ||  sudo -E $PREFIX/bin/luarocks install torch  
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install nn            ||  sudo -E $PREFIX/bin/luarocks install nn     
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install dok           ||  sudo -E $PREFIX/bin/luarocks install dok    
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install gnuplot       ||  sudo -E $PREFIX/bin/luarocks install gnuplot
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
[ -n "$cutorch" ] && \
($PREFIX/bin/luarocks install cutorch      ||  sudo -E $PREFIX/bin/luarocks install cutorch        ||   cutorch=failed )
[ -n "$cunn" ] && \
($PREFIX/bin/luarocks install cunn         ||  sudo -E $PREFIX/bin/luarocks install cunn           ||   cunn=failed )


$PREFIX/bin/luarocks install qtlua         ||  sudo -E $PREFIX/bin/luarocks install qtlua  
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install qttorch       ||  sudo -E $PREFIX/bin/luarocks install qttorch
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install luafilesystem ||  sudo -E $PREFIX/bin/luarocks install luafilesystem
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install penlight      ||  sudo -E $PREFIX/bin/luarocks install penlight 
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install sys           ||  sudo -E $PREFIX/bin/luarocks install sys      
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install xlua          ||  sudo -E $PREFIX/bin/luarocks install xlua     
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install image         ||  sudo -E $PREFIX/bin/luarocks install image    
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install optim         ||  sudo -E $PREFIX/bin/luarocks install optim    
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install lua-cjson     ||  sudo -E $PREFIX/bin/luarocks install lua-cjson
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install trepl         ||  sudo -E $PREFIX/bin/luarocks install trepl    
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi


# Done.
echo ""
echo "=> Torch7 has been installed successfully"
echo ""
echo "  + Extra packages have been installed as well:"
echo "     $ luarocks list"
echo ""
echo "  + To install more packages, do:"
echo "     $ luarocks search --all"
echo "     $ luarocks install PKG_NAME"
echo ""
echo "  + Note: on MacOS, it's a good idea to install GCC 5 to enable OpenMP."
echo "     You can do this by with brew"
echo "      $ brew install gcc --without-multilib"
echo "     type the following lines before running the installation script"
echo "      export CC=gcc-5"
echo "      export CXX=g++-5"
echo "     For installing cunn, you will need instead the default AppleClang compiler,"
echo "     which means you should open a new terminal (with unexported CC and CXX) and"
echo "      luarocks install cunn"
echo ""
echo "  + packages installed:"
echo "    - sundown   : " $sundown
echo "    - cwrap     : " $cwrap
echo "    - paths     : " $paths
echo "    - torch     : " $torch
echo "    - nn        : " $nn
echo "    - dok       : " $dok
echo "    - gnuplot   : " $gnuplot
[ -n "$cutorch" ] && echo "    - cutorch   : " $cutorch
[ -n "$cunn" ]    && echo "    - cunn      : " $cunn
echo "    - qtlua     : " $qtlua
echo "    - qttorch   : " $qttorch
echo "    - lfs       : " $lfs
echo "    - penlight  : " $penlight
echo "    - sys       : " $sys
echo "    - xlua      : " $xlua
echo "    - image     : " $image
echo "    - optim     : " $optim
echo "    - cjson     : " $cjson
echo "    - trepl     : " $trepl
echo ""

step3:installing itorch on centos

##reference web:
https://github.com/facebook/iTorch
##itorch require:
linux/torch7/ipython2.2+/zeromq

git clone https://github.com/facebook/iTorch.git
cd iTorch
luarocks make 

sudo env "PATH=$PATH" luarocks make
sudo chown -R $USER $(dirname $(ipython locate profile))

step4:installing matio
##reference web:
https://github.com/soumith/matio-ffi.torch

你可能感兴趣的:(torch7)