Installing Torch7 and OpenNMT On Ubuntu 14.04

This tutorial shows how you can install Torch7 and OpenNMT on Ubuntu.

#Install Torch7 with Lua 5.2


sudo apt-get install libreadline-dev
sudo apt-get install luarocks
luarocks install zlib

git clone https://github.com/torch/distro.git  torch  --recursive
cd torch
bash install-deps;
TORCH_LUA_VERSION=LUA52 ./install.sh

#Simple test script

th -e "require 'cutorch'; "
th -e "require 'nn'; "
th -e "require 'cunn'; "

#Install OpenNMT

git clone https://github.com/opennmt/opennmt OpenNMT
luarocks install tds

#Install CTranslate

#1.Install Boost

sudo apt-get install p7zip-full
wget   http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.7z
7z x boost_1_59_0.7z
cd boost_1_59_0
./bootstrap.sh && ./b2 -j24 --prefix=$PWD --libdir=$PWD/lib64 --layout=system link=static install || echo FAILURE

#2.install Eigen
wget http://bitbucket.org/eigen/eigen/get/3.3.1.tar.bz2
mv 3.3.1.tar.bz2  eigen_3.3.1.tar.bz2
tar -jxf eigen_3.3.1.tar.bz2 

#3.install CTranslate
cd CTranslate/include
ln -s  ~/eigen-eigen-f562a193118d/Eigen/  Eigen
mkdir build
cd build
cmake -DEIGEN_ROOT=~/eigen-eigen-f562a193118d -DCMAKE_CXX_FLAGS="-march=native"  ..
make -j24

Tips
Unless you are cross-compiling for a different architecture, you can add -DCMAKE_CXX_FLAGS="-march=native" to the cmake command above to optimize for speed.
Consider using Intel® MKL if available. You should follow Eigen instructions to link against it. https://eigen.tuxfamily.org/dox/TopicUsingIntelMKL.html

3 Likes