Torch

From UMIACS
Revision as of 21:52, 7 March 2018 by Derek (talk | contribs)
Jump to navigation Jump to search

You can compile Torch on our RHEL7 machines. Please make sure to ask staff@umiacs.umd.edu if have issues as there are some local packages that are required and could cause the install to fail.

Note you have to use Cuda 8 or Cuda 7.5 when compiling Torch and that certain newer GPU cards are not supported under Cuda 7.5. We will use Cuda 8 in this example.

First load the following software into your environment with GNU Modules.

module add cuda/8.0.61 cudnn zeromq nodejs sox GraphicsMagick 

Next we are going to create a python environment and active it (this assumes you are using the bash shell)

virtualenv env 
source env/bin/activate 

Then we are going to upgrade the python pip package manager and install two more dependencies

pip install --upgrade pip
pip install pyzmq ipython

Next clone the repository from Torch ensuring you do it with the recursive option to get all its sub dependencies.

git clone https://github.com/torch/distro.git torch --recursive 

Finally build Torch, this will take awhile.

cd torch && ./install.sh

At the end it will give you example of how to activate your Torch environment here is an example.

source install/bin/torch-activate

Now you can test you your install with the command th torch_test.th where the contents of the file torch_test.th are the following.

a = torch.Tensor(5,3)
a = torch.rand(5,3)
b = torch.rand(3,4)
c = torch.Tensor(5,4)
c:mm(a,b)

print(c)

require 'cutorch';
a = a:cuda()
b = b:cuda()
c = c:cuda()
c:mm(a,b)

print(c)