您的位置:首页 > 其它

ubuntu16安装Torch

2017-12-18 16:08 218 查看
1.下载LuaJIT(C语言编写的Lua的解释器)和Torch所必需的依赖包

$mkdir -p ~/torch     //在创建需要安装的目录位置
$cd ~/torch
$git clone https://github.com/torch/distro.git . --recursive


2.安装依赖包和Torch (执行时间可能有点长)

$./install-deps    //安装依赖包
$./install.sh      //安装Torch


3.bashrc文件配置

终端提示:
Do you want to automatically prepend the Torch install locationto PATH and LD_LIBRARY_PATH in your /home/xxxx/.bashrc? (yes/no)
$yes


4.验证Torch

//重启终端,然后输入如下命令:
$th
//如果没有报错提示,表示安装成功


5.安装其他依赖库

//如果protobuf已经安装了,可以不用再安装
$sudo apt-get install libprotobuf-dev protobuf-compiler
$luarocks install loadcaffe


6.下载neural style代码和VVG模型测试CPU/GPU

$cd ~/
$git clone https://github.com/jcjohnson/neural-style.git $cd neural-style

//下载VGG模型
$sh models/download_models.sh

//CPU版本的测试
$th neural_style.lua -gpu -1 -print_iter 1
//GPU版本的测试
$th neural_style.lua -gpu 0 -print_iter 1


6.安装cuda

$luarocks install cutorch
$luarocks install cunn
//测试一下
$th -e "require 'cutorch'; require 'cunn'; print(cutorch)"


7.安装cudnn

tar -xzvf  cudnn-8.0-linux-x64-v5.1.tgz
$sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
$sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
$luarocks install cudnn
//测试一下:
$th neural_style.lua -gpu 0 -backend cudnn
//如果提示cudnn5.1找不到,则到Nvidia官网重新下载cudnn5.1替换本地现有的其它版本的cudnn,然后重新安装$cudnn:luarocks install cunn和测试cudnn
//我本地原来的cudnn版本是v7,没办法,该torch版本只支持cudnnv5.1


8.torch测试cuda+cudnn

$cd ~/torch
$./test.sh
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu torch