Torch 7 Scientific Computer Framework with cuDNN – NVIDIA Jetson TK1

The Torch scientific computing framework is an easy to use and efficient platform with wide support for machine learning algorithms. The underlying C/CUDA implementation is accessed through a fast scripting language called LuaJIT. Installation on the Jetson TK1 is straightforward. We also add extensions for cuDNN support. Looky here:

Introduction

The Torch website lists all the good bits about why people should use Torch. There are a wide variety of applications that can be built using Torch. From the website:

Torch comes with a large ecosystem of community-driven packages in machine learning, computer vision, signal processing, parallel processing, image, video, audio and networking among others, and builds on top of the Lua community.

At the heart of Torch are the popular neural network and optimization libraries which are simple to use, while having maximum flexibility in implementing complex neural network topologies. You can build arbitrary graphs of neural networks, and parallelize them over CPUs and GPUs in an efficient manner.

The reason that you should pay attention to Torch is that it is being used by a lot of the big players in the deep learning/machine learning space, including such familiar names as Facebook, Google and Twitter.

Torch 7 Installation

Installation is straightforward. The entire installation takes about an hour. There is a script that was used for the basis of the video https://github.com/torch/ezinstall. There were some issues with permissions during installation, so I just manually entered the two installation scripts.

$ git clone https://github.com/torch/ezinstall.git
$ cd ezinstall
$ sudo ./install-deps
$ sudo ./install-luajit+torch

If you want to install the NVIDIA® cuDNN – GPU Accelerated Deep Learning extension for Torch 7, you must go to the NVIDIA site and download the library. Note: You must be a CUDA Registered Developer (it’s free to sign up) in order to download the cuDNN library. The current version is V2. Download the extension, and switch to that directory, i.e. $

cd ~/Downloads

Here’s a script to install it:

You can then switch back to your Home directory.
Once the cuDNN library is installed, you can then install the Torch extensions for cuDNN:

$ sudo luarocks install cutorch
$ sudo luarocks install cunn
$ sudo luarocks install cudnn

FYI, luarocks install cudnn will install Torch bindings (written by Soumith, https://github.com/soumith/cudnn.torch) for cuDNN library.

Notes

Torch 7 tends to use a lot of memory. If you use Torch, you will probably need to have a swap file set up. You can refresh your memory on how to do that here on another blog entry on JetsonHacks.

This installation installs Torch 7 on a NVIDIA Jetson TK1 running Linux for Tegra (L4T) 21.3 with CUDA 6.5. The installation was done over a fresh install using JetPack 1.1. For more information about doing a fresh install, see this blog entry on JetsonHacks.

10 Comments

  1. I have followed the above steps but Im unable to install the Torch extensions for cuDNN.

    This is the error I get upon typing in,

    sudo luarocks install cutorch

    Installing https://raw.githubusercontent.com/torch/rocks/master/cutorch-scm-1.rockspec
    Using https://raw.githubusercontent.com/torch/rocks/master/cutorch-scm-1.rockspec… switching to ‘build’ mode
    Cloning into ‘cutorch’…
    remote: Counting objects: 82, done.
    remote: Compressing objects: 100% (79/79), done.
    remote: Total 82 (delta 7), reused 31 (delta 0), pack-reused 0
    Receiving objects: 100% (82/82), 134.67 KiB | 134.00 KiB/s, done.
    Resolving deltas: 100% (7/7), done.
    Checking connectivity… done.
    cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=”/usr/local/bin/..” -DCMAKE_INSTALL_PREFIX=”/usr/local/lib/luarocks/rocks/cutorch/scm-1″ && make -j$(getconf _NPROCESSORS_ONLN) install

    — The C compiler identification is GNU 4.8.4
    — The CXX compiler identification is GNU 4.8.4
    — Check for working C compiler: /usr/bin/cc
    — Check for working C compiler: /usr/bin/cc — works
    — Detecting C compiler ABI info
    — Detecting C compiler ABI info – done
    — Check for working CXX compiler: /usr/bin/c++
    — Check for working CXX compiler: /usr/bin/c++ — works
    — Detecting CXX compiler ABI info
    — Detecting CXX compiler ABI info – done
    — Found Torch7 in /usr/local
    CMake Error at /usr/share/cmake-2.8/Modules/FindCUDA.cmake:548 (message):
    Specify CUDA_TOOLKIT_ROOT_DIR
    Call Stack (most recent call first):
    CMakeLists.txt:7 (FIND_PACKAGE)

    — Configuring incomplete, errors occurred!
    See also “/tmp/luarocks_cutorch-scm-1-2557/cutorch/build/CMakeFiles/CMakeOutput.log”.

    Error: Build error: Failed building.

  2. Hi,

    When I try to install Torch on my Jetson TK1 (L4T 21.1, CUDA 6.5) I get the following problem:

    “Package libopenblas-dev is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsolete, or is only available from another source

    E: Package ‘libopenblas-dev’ has no installation candidate”

    The same error appears when I follow the installation instructions form the torch website.

    I’ve tried to download and install the package ‘libopenblas-dev’ from ‘https://launchpad.net/ubuntu/+source/openbl’. However, during the installation processed I get an error message saying that the Jetson CPU architecture is not suitable for the libopenblas library.

    Any ideas on how to solve this problem?

    Thanks a lot

    PS: The tutorials are great, crystal clear

  3. Sorry, I forgot to mention. I’ve done

    sudo apt-get update

    and the problem still persists. Also, I have libblas-dev installed in the Jetson.

    Cheers

    • Hi Jose,
      It’s hard to tell from your comment to which problems you are referring. Are you have an issue that is noted in the comments section. If so, which version of L4T and cuDNN are you using? Did you use JetPack to install them, and which version is installed?

      • Dear Thank for answers. I passed my problem. Just I tried to search some coherent answer and the previous answer was not complete to me. That;s all. Thanks.

Leave a Reply

Your email address will not be published.


*