Torch compilation requires a number of standard packages described below:
Installation of gcc should be done by installing the the Apple developer tools. These tools should also be available on you MacOS X installation DVD.
CMake can be retrieved from CMake website (you can take the DMG installer). However, we found it was as simple to use MacPorts, which are necessary anyways for Subversion and the Readline library. We recommend to avoid Fink, which tends to be always outdated. Assuming you installed MacPorts, just do:
sudo port install readline-5 sudo port install cmake sudo port install subversion
Note: you need CMake 2.6 or newer to compile Torch, so be sure you have up-to-date ports beforehand with:
sudo port sync
For installing QT 4.4 you can also run
sudo port install qt4-macHowever, compiling QT 4.4 requires a good amount of time (a bit less than 2h on my Macbook Pro 2.4Ghz). If you cannot wait, download instead the binary DMG file available on Trolltech website and install it.
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.