Installing Neural Style on Ubuntu

Install Git

If you have not already done so, you will need to install Git.

$ sudo apt-get install git

Install Torch

Easy to follow guide:

Do this first!  Do not install Luarocks or Luajit.  The Torch installation comes with Luarocks and Luajit.  If you install them separately, it will mess up the path, and some of the other programs will not work.

$ git clone ~/torch --recursive
$ cd ~/torch; bash install-deps;
$ ./

Update PATH.

source ~/.bashrc

Install Loadcaffe


$ sudo apt-get install libprotobuf-dev protobuf-compiler
$ luarocks install loadcaffe

Do not use sudo for the Luarocks commands.  After installing loadcaffe, install image and nn.  This adds functionality for different image types and neural networks.

$ luarocks install image
$ luarocks install nn

Install Neural Style


installation guide:

$ git clone

Do not use sudo.

$ cd neural-style
$ sh models/

To run the program, use the command:

th neural_style.lua -style_image <style image file> -content_image <picture file> -gpu -1

This runs the program using CPU.

(optional)  Install CUDA and CuDNN

If you have an NVIDIA card, using GPU acceleration will make Neural Style run a lot faster.

How to install CUDA and CuDNN:

Once you’ve done that, you can enable the features in Torch.

$ luarocks install cutorch
$ luarocks install cunn

$ luarocks install cudnn

The command for GPU acceleration is:

th neural_style.lua -style_image <style image file> -content_image <picture file> -gpu 0 -backend cudnn






Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge