转载请注明出处:

http://www.cnblogs.com/darkknightzh/p/5653864.html

参考网址:

http://torch.ch/docs/getting-started.html

http://deepdish.io/2015/02/20/local-torch-installation/

160714说明:如果需要使用torch及GraphicsMagick并读取jpg图像的话,最好先安装libjpeg的库,然后在安装GraphicsMagick,最后再安装torch。

因为刚才GraphicsMagick调用jpeg没有错误,但是torch里面的某个模块又提示找不到libjpeg.so的库了,之后只能先强制卸载image包:luarocks remove image --force,再重新luarocks install image。之后正常了。。。

1. 先安装luarocks

sudo apt-get install luarocks

2. 安装torch

http://torch.ch/docs/getting-started.html

1) 终端中输入:

git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh

说明: ~/torch应该就是终端当前所在的文件夹(默认时为/home/XXX/,加了~/torch后就变成了/home/XXX/torch)

2) 将torch添加到PATH中

source ~/.bashrc

160713说明:今天在另一台电脑上安装了torch7和ZeroBrane,启动ZeroBrane后,程序第一句require 'image'就错误,提示找不到image包。后来网上搜了一下,也有人遇到了这个问题。主要就是环境变量

http://deepdish.io/2015/02/20/local-torch-installation/说了,可以将以下语句加入到~/.bashrc中:

export TORCH_DIR=$HOME/torch
export LUA_PATH="$TORCH_DIR/install/share/lua/5.1/?.lua;$TORCH_DIR/install/share/lua/5.1/?/init.lua;$TORCH_DIR/install/share/luajit-2.1.0-alpha/?.lua"
export LUA_CPATH="$TORCH_DIR/install/lib/lua/5.1/?.so"

自己发现,执行完source ~/.bashrc后,~/.bashrc中多了一条语句:

. /home/XXX/program/torch/install/bin/torch-activate

这条语句中torch-activate就是包含torch安装的库目录的文件。然后重启电脑,再使用ZeroBrane的话,就不会提示找不到image包了。。。

由于没有重启电脑,害的我卸了torch又重新装了几次。。。哎。。。

现在感觉,如果再碰到这个问题,实在不行的话,就自己手动把torch-activate文件的路径加到.bashrc中,然后重启电脑试试。不行的话,额,不行再想办法吧。。。

3) 如果需要的话,卸载torch

rm -rf ~/torch

说明:上面安装的是torch和LuaJIT,如果希望安装torch和Lua5.2,而不是LuaJIT,则:

git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch # clean old torch installation
./clean.sh
# optional clean command (for older torch versions)
# curl -s https://raw.githubusercontent.com/torch/ezinstall/master/clean-old.sh | bash # https://github.com/torch/distro : set env to use lua
TORCH_LUA_VERSION=LUA52 ./install.sh

5) 安装完torch后输入th:

3. 安装torch的包(packages),如nndpnn

说明:安装先安装nn,再安装dpnn

1) 下载nn和dpnn:

https://github.com/torch/nn

https://github.com/nicholas-leonard/dpnn

2) 解压这两个文件夹。

3) 终端中cd到这两个文件夹上一级目录。

4) 使用luarocks install命令进行安装

luarocks install nn-master/rocks/nn-scm-.rockspec
luarocks install dpnn-master/rocks/dpnn-scm-.rockspec

说明:① 官网中说直接使用命令luarocks install dpnn进行安装,但是会提示:

No results matching query were found

② nn和dpnn都有依赖的包,需要先安装好。具体都有啥,忘了。。。不过dpnn依赖的比nn多。

③ 官网说可以使用Luarocks在终端中安装packages,比如:

luarocks install image

但是如果安装失败的话,就按照3中①-④的步骤,先下载下来,然后再安装。。。

④ 查看都安装了哪些包:

luarocks list

(原)ubuntu上安装Torch7及nn及dpnn的更多相关文章

  1. 在Ubuntu上安装Odoo时遇到的问题

    这两天开始看<Odoo快速入门与实践  Python开发ERP指南>(刘金亮 2019年5月第1版 机械工业出版社).试着在Ubuntu上安装Odoo,遇到很多问题,通过在网上查找,都已解 ...

  2. [异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议

    一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题 ...

  3. Ubuntu上安装Robomongo及添加到启动器

    到目前为止,Robomongo仍是MongoDB最好的客户端管理工具,如需在Ubuntu上安装Robomongo,可直接从官网下载.tar.gz压缩包进行解压,然后直接运行bin目录下的robomon ...

  4. 在 Ubuntu 上安装 Android Studio

    在 Ubuntu 上安装 Android Studio http://www.linuxidc.com/Linux/2013-05/84812.htm 打开terminal,输入以下命令 sudo a ...

  5. Ubuntu上安装Karma失败对策

    在Ubuntu上安装Karma遇到超时 timeout 错误.Google了一下,国外的码农给了一个快捷的解决方案,实测可行,贴在这里: sudo apt-get install npm nodejs ...

  6. 在Ubuntu上安装LAMP服务器

    1.安装Ubuntu上安装LAMP apt-get install lamp-server^ 2.安装过程中设置MySql密码 3.测试 创建index.php var/www/html/index. ...

  7. [译]How to Setup Sync Gateway on Ubuntu如何在ubuntu上安装sync-gateway

    参考文章https://hidekiitakura.com/2015/03/21/how-to-setup-sync-gateway-on-ubuntudigitalocean/ 在此对作者表示感谢 ...

  8. 在Ubuntu上安装JDK、Ant、Jmeter和Jenkins

    一.前期准备 1. 在win7下载VMware.Ubuntu(用迅雷下比较快) 2. 安装完VMware后新建虚拟机,选择iso: 3. 具体配置参考如下,至此Ubantu安装完成 二.在Ubuntu ...

  9. Ubuntu上安装MongoDB(译)

    add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/ ...

随机推荐

  1. C#如何设置下拉COMMBOX为不可输入,只有下拉条目

    设置下拉框的DropDownStyle属性为DropDownList

  2. Protobuf, understand the hood

    proto文件定义 package lm; message Foo{ required int32 id = 1; } message Bar{ required int32 id = 1 [defa ...

  3. freemarker中遍历list<map<String,String>>

    <#list var as map><tr> <#list map?keys as itemKey> //关键点    <#if itemKey=" ...

  4. Creating a settings table that can handle almost any type of value

    Update: Updated article here. Today I wanted to be able to have a table store any type of value as a ...

  5. Halloween party

    https://www.hackerrank.com/challenges/halloween-party def main(): t = int(raw_input()) for _ in rang ...

  6. centos在安装apache2.4版本的时候遇到ARP not found解决办法

    今日编译apache时出错: #./configure --prefix……检查编辑环境时出现: checking for APR... noconfigure: error: APR not fou ...

  7. Django的 select_related 和 prefetch_related 函数对 QuerySet 查询的优化(一)

    在数据库有外键的时候,使用 select_related() 和 prefetch_related() 可以很好的减少数据库请求的次数,从而提高性能.本文通过一个简单的例子详解这两个函数的作用.虽然Q ...

  8. 使用OpenSSL生成证书

    使用OpenSSL生成证书 下载安装openssl,进入/bin/下面,执行命令(把ssl目录下的openssl.cnf 拷贝到bin目录下)1.首先要生成服务器端的私钥(key文件):openssl ...

  9. Absolute sort

    Absolute sort Let's try some sorting. Here is an array with the specific rules. The array (a tuple) ...

  10. cf448A Rewards

    A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...