Check out the latest superpixel benchmark — Superpixel Benchmark (2016) — and let me know your opinion! @david_stutz

SERIES»Working with Ubuntu«

Installing Torch and iTorch, Installing ZeroBrane Studio with Torch Support

In this series, I blog about development and research with Ubuntu. This time: how to install LUA, Torch and iTorch and use Torch from within ZeroBrane Studio.

Torch can easily be installed from the repository and includes LUAJit:

git clone https://github.com/torch/distro.git ~/torch-master --recursive
cd ~/torch-master
bash install-deps
# Installation will take longer with CUDA and CuDNN:

At the end, the installer will add the following line to the bash profile:

. ~/torch-master/install/bin/torch-activate

After starting a new console, the installation can be tested by running the interactive Torch console:

  ______             __   |  Torch7 
 /_  __/__  ________/ /   |  Scientific computing for Lua. 
  / / / _ \/ __/ __/ _ \  |  Type ? for help 
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch 
                          |  http://torch.ch 
th> require 'torch'
# will list all the functions ...

To work with Torch in an iPython (or Jupyter) notebook, Facebook provides a Torch kernel. The following assumes that iPython and Jupyter are already installed:

# Console should be restarted after installing Torch:
sudo apt-get install libzmq3-dev libssl-dev python-zmq
sudo apt-get install luarocks
luarocks install lzmq --local
luarocks install image --local
git clone https://github.com/facebook/iTorch.git iTorch-master
cd iTorch-master
luarocks make --local

The kernel can be tested by running jupyter notebook and looking for the iTorch kernel.

ZeroBrane Studio can easily be installed from the website or as follows:

wget https://download.zerobrane.com/ZeroBraneStudioEduPack-1.50-linux.sh
chmod +x ZeroBraneStudioEduPack-1.50-linux.sh
sudo ./ZeroBraneStudioEduPack-1.50-linux.sh
rm ZeroBraneStudioEduPack-1.50-linux.sh

In order to run Torch from within ZeroBrane Studio, it needs to know where Torch's binary is located:

export TORCH_BIN=~/torch-master/install/bin/th

By starting ZeroBrane Studio from console (after creating a new console instance) using zbstudio, Torch can easily be used; test it using

require 'torch'

More from »Working with Ubuntu«:

What is your opinion on this article? Did you find it interesting or useful? Let me know your thoughts in the comments below or get in touch with me:


  • piratla aditya


    Thanks for the instructions and tutorial.

    I am facing problems while installing as my office restricts me from accessing https://rocks.moonscript.org/manifest, because of which

    luarocks install image –local command for installing the image module is throwing an error:

    Failed searching manifest: Failed fetching manifest for https://rocks.moonscript.org
    Failed downloading https://rocks.moonscript.org/manifest

    So, I thought I would download the manifest file and use it directly, but I am not sure how to use the manifest file, it does
    not seem to be an installation script.

    Can you please help me with the same.

    Thanks in advance..

    Aditya Piratla

    • davidstutz

      Hmm … I am afraid I can’t directly help you. But if

      luarocks install image –local

      does not work out-of-the-box, you can also fetch the latest version from GitHub: https://github.com/torch/image

      Then, the included .rockspec file can be used for installing image, e.g.

      luarocks install image-1.1.alpha-0.rockspec

      You may need to adapt the exact .rockspec file for later versions. Hope that helps ;)