ubuntu14.04安装lua+luarocks+torch

安装lua 

wget http://www.lua.org/ftp/lua-5.3.5.tar.gz
tar -zxvf lua-5.3.5.tar.gz
cd lua-5.3.5

sudo apt-get install build-essential gcc
sudo apt-get install libreadline6 libreadline6-dev

make linux
sudo make install

安装luarocks 

cd ~
wget http://keplerproject.github.io/luarocks/releases/luarocks-2.2.2.tar.gz
tar -xzvf luarocks-2.2.2.tar.gz
cd luarocks-2.2.2

sudo ./configure --prefix=/usr/local/luarocks
sudo make build
sudo make install

sudo mkdir -p /usr/local/luarocks/lib/lua/5.3
sudo apt-get install vim
sudo vim ~/.bashrc

# 在最后面加上下面的5句话
PATH=$PATH:$HOME/bin:/usr/local/luarocks/bin:/usr/local/bin
export PATH 
export LUA_PATH="/usr/local/luarocks/share/lua/5.3/?.lua;?.lua;;"
export LUA_CPATH="/usr/local/luarocks/lib/lua/5.3/?.so;?.so;;"
alias sudo='sudo env PATH=$PATH LUA_PATH=$LUA_PATH LUA_CPATH=$LUA_CPATH'

source ~/.bashrc

测试一下 

sudo luarocks install luasocket

lua

require('socket')

 安装torch

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

source ~/.bashrc
source ~/.profile

如果用lua安装

git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
./clean.sh
curl -s https://raw.githubusercontent.com/torch/ezinstall/master/clean-old.sh | bash
bash install-deps

TORCH_LUA_VERSION=LUA53 ./install.sh

source ~/.bashrc
source ~/.profile

git clone https://github.com/torch/nn ~/nn-master --recursive
git clone https://github.com/nicholas-leonard/dpnn ~/dpnn-master --recursive
luarocks install ~/nn-master/rocks/nn-scm-1.rockspec
luarocks install ~/dpnn-master/rocks/dpnn-scm-1.rockspec
 
 
luarocks install image
luarocks install optim
luarocks install gnuplot
luarocks install paths
luarocks install trepl
luarocks install cwrap
luarocks install qtlua

# 如果有cuda可以
luarocks install cutorch

测试一下

cd ~/torch
./test.sh

我的报错的信息

//因为虚拟机没有cuda

/home/nightmare/torch/install/bin/lua: module 'cutorch' not found:
	no field package.preload['cutorch']
	no file '/home/nightmare/.luarocks/share/lua/5.3/cutorch.lua'
	no file '/home/nightmare/.luarocks/share/lua/5.3/cutorch/init.lua'
	no file '/home/nightmare/torch/install/share/lua/5.3/cutorch.lua'
	no file '/home/nightmare/torch/install/share/lua/5.3/cutorch/init.lua'
	no file '/home/nightmare/.luarocks/share/lua/5.1/cutorch.lua'
	no file '/home/nightmare/.luarocks/share/lua/5.1/cutorch/init.lua'
	no file '/home/nightmare/torch/install/share/lua/5.1/cutorch.lua'
	no file '/home/nightmare/torch/install/share/lua/5.1/cutorch/init.lua'
	no file '/usr/local/luarocks/share/lua/5.3/cutorch.lua'
	no file 'cutorch.lua'
	no file './cutorch.lua'
	no file '/home/nightmare/torch/install/share/luajit-2.1.0-beta1/cutorch.lua'
	no file '/usr/local/share/lua/5.1/cutorch.lua'
	no file '/usr/local/share/lua/5.1/cutorch/init.lua'
	no file '/home/nightmare/torch/install/lib/cutorch.so'
	no file '/home/nightmare/.luarocks/lib/lua/5.3/cutorch.so'
	no file '/home/nightmare/torch/install/lib/lua/5.3/cutorch.so'
	no file '/home/nightmare/torch/install/lib/cutorch.so'
	no file '/home/nightmare/.luarocks/lib/lua/5.1/cutorch.so'
	no file '/home/nightmare/torch/install/lib/lua/5.1/cutorch.so'
	no file '/usr/local/luarocks/lib/lua/5.3/cutorch.so'
	no file 'cutorch.so'
	no file './cutorch.so'
	no file '/usr/local/lib/lua/5.1/cutorch.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
	[C]: in function 'require'
	[C]: in ?
CUDA not found

 

参考资料:

https://ubuntuqa.com/article/2448.html

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

你可能感兴趣的:(安装与配置)