centos7 安装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
 
# 安装依赖
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

Leave a Comment