A. Requirements

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-mac
However, 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.gz
where XXX is the version you downloaded. This will create a directory corresponding to the name of the archive, that you should rename as torch.

However, we recommend to use the subversion repository to keep bleeding edge sources.

svn checkout https://torch5.svn.sourceforge.net/svnroot/torch5/trunk torch
This will create a torch directory. If you prefer another directory name, replace the last torch by the name you want in the above svn command.

C. Configuring Torch

We use 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 .. given to cmake indicates the directory where the sources are. We chose here to have a build directory inside torch, but it could be anywhere else. In that latter case, go instead in your build directory and then do:
cmake /path/to/torch/sources

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 cmake by ccmake in 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 to CMake on the above cmake command:

cmake .. -DCMAKE_INSTALL_PREFIX=/my/install/path
Equivalently you can set the variable CMAKE_INSTALL_PREFIX if you use ccmake GUI. 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:

make
and then install it with:
make install
This last command might possibly be prefixed by sudo if you are installing Torch in /usr/local.

E. Running Torch

Now Torch should be installed in /usr/local or in /my/install/path if you chose to use the CMAKE_INSTALL_PREFIX when configuring with CMake. Lua executables (lua and 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 PATH the path to lua binaries. The executable lua is a simple Lua interpreter (as provided on Lua website), while qlua has enhanced interactivity (like completion) and is able to handle graphics and QT widgets.