Installing Torch7 and OpenNMT On Ubuntu 14.04

(Netxiao) #1

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  torch  --recursive
cd torch
bash install-deps;

#Simple test script

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

#Install OpenNMT

git clone OpenNMT
luarocks install tds

#Install CTranslate

#1.Install Boost

sudo apt-get install p7zip-full
7z x boost_1_59_0.7z
cd boost_1_59_0
./ && ./b2 -j24 --prefix=$PWD --libdir=$PWD/lib64 --layout=system link=static install || echo FAILURE

#2.install Eigen
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

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.

Tokenize.lua results in