Torch compilation requires a number of standard packages described below:
The installation of most of these packages should be rather straightforward. For
based systems we use the
apt-get install gcc g++ apt-get install cmake apt-get install libreadline5-dev apt-get install subversionPlease adapt according to your distribution.
Note: readline library is helpful for better command line interaction, but it is not required.
Note: while CMake 2.4.7 or newer will (kind of) work, we like to use CMake 2.6 which is much less buggy. CMake installation is easy and fast from the sources available on CMake website. Follow their instructions for that purpose.
QT 4.4 for handling graphics (beware not installing QT 4.3
or older). If it is not found at compile time, Torch will still compile but
no graphics will be available. On recent Debian distribution you can
install it with
apt-get install libqt4-core libqt4-gui libqt4-devIf QT 4.4 is not available on your system you should follow our additional instructions for QT 4.4.
CBLAS installation is also recommended for speed. If not found, Torch will rely on hand-made linear algebra routines.
Debian distribution provide CBLAS through the
apt-get install refblas3-devUltimate speed is achieved using the Intel MKL library. We support at the time only MKL 9, as we get weird runtime errors with MKL 10. Follow Intel instruction to unpack MKL. Then make sure the libraries relevant for your system (e.g.
em64tif you are on a 64 bits distribution) are available in your
B. Getting Torch sources
You can download the last tarball sources and unpack it with
tar xfvz Torch5-XXX-Source.tar.gzwhere
XXXis the version you downloaded. This will create a directory corresponding to the name of the archive, that you should rename as
However, we recommend to use the subversion repository to keep bleeding edge sources.
svn checkout https://torch5.svn.sourceforge.net/svnroot/torch5/trunk torchThis will create a
torchdirectory. If you prefer another directory name, replace the last
torchby the name you want in the above
C. Configuring Torch
CMake for configuring
Torch. We highly recommend to create
first a dedicated build directory. This eases cleaning up built objects,
but also allow you to build Torch with various configurations
(e.g. Release and Debug in two different build directories).
cd torch mkdir build cd build cmake ..The
cmakeindicates the directory where the sources are. We chose here to have a
torch, but it could be anywhere else. In that latter case, go instead in your build directory and then do:
CMake detects external libraries or tools necessary for Torch, and produces
Makefiles such that Torch is then easily compilable on your platform. If
you prefer the GUI version of CMake, you can replace
the above command lines. In particular, it is strongly encouraged to use
ccmake for finer configuration of Torch.
The most common Torch configuration step you might want to perform is changing the
installation path. By default, Torch will be installed in
/usr/local. You will need super-user rights to perform that. If you are
not root on your computer, you can instead specifying a install directory
CMake on the above
cmake .. -DCMAKE_INSTALL_PREFIX=/my/install/pathEquivalently you can set the variable
CMAKE_INSTALL_PREFIXif you use
ccmakeGUI. Please, see CMake documentation or at least some of our CMake hints for more details on configuration.
D. Compiling and installing
If the configuration was successful, Makefiles should have appeared in your build directory. Compile Torch with:
makeand then install it with:
make installThis last command might possibly be prefixed by
sudoif you are installing Torch in
E. Running Torch
Now Torch should be installed in
/usr/local or in
you chose to use the
CMAKE_INSTALL_PREFIX when configuring with CMake.
Lua executables (
qlua) are found in the
bin sub-directory of
these installation directories.
/usr/local/bin/lua Lua 5.1.3 Copyright (C) 1994-2008 Lua.org, PUC-Rio > require 'torch' > = torch.Tensor(5):zero() 0 0 0 0 0 [torch.Tensor of dimension 5] >For convenience, you might want to add to your
PATHthe path to lua binaries. The executable
luais a simple Lua interpreter (as provided on Lua website), while
qluahas enhanced interactivity (like completion) and is able to handle graphics and QT widgets.