Torch - ArchWiki

# Torch

This article or section needs language, wiki syntax or style improvements.

Reason: Not Help:Style-compliant. (Discuss)

The factual accuracy of this article or section is disputed.

Reason: There is torch7 in the AUR. (Discuss)

Torch7 is a scientific computing framework with wide support for machine learning algorithms. It is easy to use and provides a very efficient implementation, thanks to an easy and fast scripting language, LuaJIT, and an underlying C implementation.

Torch installation instructions are available at the main Torch website [1] but rely on apt-get under Linux. The simple instructions below explain how to modify the scripts to work with pacman.

## Download scripts

Download the two install scripts,

    $ curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-deps > install-deps
    $ curl -sk https://raw.githubusercontent.com/torch/ezinstall/master/install-luajit+torch > install-luajit+torch

## Modify scripts

The `install-luajit+torch` script doesn't require any modification. The `install-deps` script uses `apt-get` to install dependencies required for Torch. Modify the script by commenting out all lines starting with `sudo apt-get install` as well as the conditional:

    if [[ `which apt-get` == '' ]]; then
            echo '===> apt-get not found, platform not supported'
            exit
    fi

Afterwards, insert the appropriate `pacman -S` commands to install the required packages. Depending on which packages are already installed on your system you may not need to install all of them. Please edit this Wiki page with the respective pacman packages if the following isn't sufficient.

    install-deps

        # Install dependencies for Torch:
        # sudo apt-get install -y python-software-properties
        # sudo add-apt-repository ppa:chris-lea/zeromq
        # sudo add-apt-repository ppa:chris-lea/node.js
        # sudo apt-get update
        # sudo apt-get install -y build-essential
        # sudo apt-get install -y gcc g++
        # sudo apt-get install -y cmake
        # sudo apt-get install -y curl
        # sudo apt-get install -y libreadline-dev
        # sudo apt-get install -y git-core
        # sudo apt-get install -y libqt4-core libqt4-gui libqt4-dev
        # sudo apt-get install -y libjpeg-dev
        # sudo apt-get install -y libpng-dev
        # sudo apt-get install -y ncurses-dev
        # sudo apt-get install -y imagemagick
        # sudo apt-get install -y libzmq-dev
        # sudo apt-get install -y gfortran
        # sudo apt-get install -y unzip
        # sudo apt-get install -y gnuplot
        # sudo apt-get install -y gnuplot-x11
        # sudo add-apt-repository ppa:chris-lea/zeromq
        # sudo apt-get update

        pacman -S cmake
        pacman -S curl
        pacman -S git
        pacman -S qt4
        pacman -S libjpeg-turbo
        pacman -S libpng
        pacman -S ncurses
        pacman -S imagemagick
        pacman -S gcc-fortran
        pacman -S unzip
        pacman -S readline
        pacman -S zeromq
        pacman -S gnuplot

## Install

Run the two scripts in order,

    $ bash install-deps
    $ bash install-luajit+torch

Lastly, you may need to run `pacman -S luajit` as well. To confirm success try running `th` from your prompt and you should get the Torch REPL. To test the install try a few `require 'MODULE_NAME'` inside the Torch prompt such as `require 'nn'` and `require 'image'`.

I recommend you then follow through with the tutorial available here [2].

Category:

- Mathematics and science