ubuntu16安装Torch

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
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿尔发go

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值