其实centos7已经装了lua5.1.4
以lua5.3.5为例
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
# 安装依赖
yum -y install gcc gcc-c++
yum -y install libtermcap-devel ncurses-devel libevent-devel readline-devel
make linux
make install
cd /usr/bin
rm -rf lua luac
ln -s /usr/local/bin/lua /usr/bin/lua
ln -s /usr/local/bin/luac /usr/bin/luac
lua -v
安装luarocks
以luarocks2.2.2为例
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
#后面的--with-lua是根据lua-5.3.5中的INSTALL_TOP的,所以如果你修改过了,就把--with-lua=后面的改了
./configure --prefix=/usr/local/luarocks-2.2.2 --with-lua=/usr/local
make build
make install
vim /etc/profile
# 在最后面加上下面的4句话
PATH=$PATH:$HOME/bin:/usr/local/luarocks-2.2.2/bin:/usr/local/bin
export PATH
export LUA_PATH="/usr/local/luarocks-2.2.2/share/lua/5.3/?.lua;?.lua;;"
export LUA_CPATH="/usr/local/luarocks-2.2.2/lib/lua/5.3/?.so;?.so;;"
#刷新环境变量
source /etc/profile
测试一下:
luarocks install luasocket
lua
#如果不报错就成功了
require('socket')
安装torch
yum -y install git
yum -y install cmake
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch
bash install-deps
./install.sh
# 最后输入yes
source ~/.bashrc
source ~/.profile
# 测试
th
如果用lua安装的话(还没有测出问题)
yum install git
yum install cmake
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
下面的是按照lua那个安装方法测试的
我的结果如下
【因为我用的虚拟机,所以没有cuda】
Completed 215579 asserts in 212 tests with 0 failures and 0 errors
/root/torch/install/bin/lua: module 'cutorch' not found:
no field package.preload['cutorch']
no file '/root/.luarocks/share/lua/5.3/cutorch.lua'
no file '/root/.luarocks/share/lua/5.3/cutorch/init.lua'
no file '/root/torch/install/share/lua/5.3/cutorch.lua'
no file '/root/torch/install/share/lua/5.3/cutorch/init.lua'
no file '/root/.luarocks/share/lua/5.1/cutorch.lua'
no file '/root/.luarocks/share/lua/5.1/cutorch/init.lua'
no file '/root/torch/install/share/lua/5.1/cutorch.lua'
no file '/root/torch/install/share/lua/5.1/cutorch/init.lua'
no file '/usr/local/luarocks-2.2.2/share/lua/5.3/cutorch.lua'
no file 'cutorch.lua'
no file './cutorch.lua'
no file '/root/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 '/root/torch/install/lib/cutorch.so'
no file '/root/.luarocks/lib/lua/5.3/cutorch.so'
no file '/root/torch/install/lib/lua/5.3/cutorch.so'
no file '/root/torch/install/lib/cutorch.so'
no file '/root/.luarocks/lib/lua/5.1/cutorch.so'
no file '/root/torch/install/lib/lua/5.1/cutorch.so'
no file '/usr/local/luarocks-2.2.2/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