Google Code Block

2016年12月1日

Environment Setup for Torch and fast-neural-style on Ubuntu

1. Install CUDA 8.0 and CUDNN 5.1

Please refer to Setup CUDA / CUDNN and Chainer for deep learning on Ubuntu 16.04


2. Install Torch from Torch#GetStarted

# in a terminal, run the commands WITHOUT sudo
git clone https://github.com/torch/distro.git ~/torch --recursive cd ~/torch; bash install-deps; ./install.sh # On Linux with bash
source ~/.bashrc

3. Install lua dependencies from torch/rocks on GitHub

git clone https://github.com/torch/rocks

luarocks install totem-0-0.rockspec  && 
luarocks install util-0-0.rockspec  && 
luarocks install fn-0-0.rockspec  && 
luarocks install pprint-0-0.rockspec  && 
luarocks install logroll-0-0.rockspec  && 
luarocks install hdf5-20-0.rockspec  &&

4. Run a Torch project : fast-neural-style

git clone https://github.com/jcjohnson/fast-neural-style

 - Generate a styled image
th fast_neural_style.lua -model models/eccv16/starry_night.t7 -input_image images/content/chicago.jpg -output_image out.png

Setup CUDA / CUDNN and Chainer for deep learning on Ubuntu 16.04



。Install CUDA / CUDNN and Chainer with GPU enabled

1 . Install CUDA 8.0 ( Ubuntu 14.04 )
    1. download http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_8.0.44-1_amd64.deb
    2. sudo dpkg -i cuda-repo-ubuntu1404_8.0.44-1_amd64.deb
    3. sudo apt-get update
    4. sudo apt-get install cuda
2 . Install CUDNN 5.1 for CUDA 8.0
    1. Download https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod/8.0/cudnn-8.0-linux-x64-v5.1-tgz
    2. Extract tgz file
    3. sudo cp lib64/* /usr/local/cuda/lib64/
    4. sudo cp include/* /usr/local/cuda/include/
3. Set environment to build Chainer
    1. export CFLAGS=-I/usr/local/cuda/include
    2. export LDFLAGS=-L/usr/local/cuda/lib64
    3. export LD_LIBRARY_PATH=/usr/local/cuda/lib64
4. pip install chainer --no-cache-dir -vvvv


5. Don't forget to setup the nvcc path
nano ~/.bashrc ( or nano ~/.zshrc if you use zsh :p )
add the following line to the end of the rc file
export PATH=/usr/local/cuda/bin:$PATH


。If you need image processing library on Python ...
pip install Pillow


。Install ffmpeg
tar xvf ffmpeg-release-64bit-static.tar

sudo cp ffmpeg-3.2-64bit-static/* /usr/local/bin/