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
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),如nn和dpnn
说明:安装先安装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-1.rockspec
luarocks install dpnn-master/rocks/dpnn-scm-1.rockspec
说明:
① 官网中说直接使用命令luarocks install dpnn进行安装,但是会提示:
No results matching query were found
② nn和dpnn都有依赖的包,需要先安装好。具体都有啥,忘了。不过dpnn依赖的比nn多。
③ 官网说可以使用Luarocks在终端中安装packages,比如:
luarocks install image
但是如果安装失败的话,就按照3中①-④的步骤,先下载下来,然后再安装。
④ 查看都安装了哪些包:
luarocks list