forked from torch/ezinstall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-luajit+torch
executable file
·157 lines (148 loc) · 6.05 KB
/
install-luajit+torch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
######################################################################
# Torch install
#
# This script installs Torch7, and a few extra packages
# (penlight, optim, parallel, image).
#
# The install is done via Luarocks, which enables package
# versions. This is the recommended method to deploy Torch,
# torch-pkg is being deprecated.
#
# Once this script has been run once, you should be able to run
# extra luarocks commands, and in particular install new packages:
# $ luarocks install json
# $ torch
# > require 'json'
#
######################################################################
# Prefix:
PREFIX=${PREFIX-/usr/local}
echo "Installing Torch into: $PREFIX"
if [[ `uname` == 'Linux' ]]; then
export CMAKE_LIBRARY_PATH=/opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
fi
# Build and install Torch7
cd /tmp
git clone https://github.com/torch/luajit-rocks.git
cd luajit-rocks
mkdir build; cd build
git checkout master; git pull
rm -f CMakeCache.txt
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_BUILD_TYPE=Release
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
make install || sudo -E make install
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
# check if we are on mac and fix RPATH for local install
path_to_install_name_tool=$(which install_name_tool)
if [ -x "$path_to_install_name_tool" ]
then
install_name_tool -id ${PREFIX}/lib/libluajit.dylib ${PREFIX}/lib/libluajit.dylib
fi
# Statuses:
sundown=ok
cwrap=ok
paths=ok
torch=ok
nn=ok
dok=ok
gnuplot=ok
qtlua=ok
qttorch=ok
lfs=ok
penlight=ok
sys=ok
xlua=ok
image=ok
optim=ok
cjson=ok
trepl=ok
path_to_nvcc=$(which nvcc)
if [ -x "$path_to_nvcc" ]
then
cutorch=ok
cunn=ok
fi
# Install base packages:
$PREFIX/bin/luarocks install sundown || sudo -E $PREFIX/bin/luarocks install sundown
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install cwrap || sudo -E $PREFIX/bin/luarocks install cwrap
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install paths || sudo -E $PREFIX/bin/luarocks install paths
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install torch || sudo -E $PREFIX/bin/luarocks install torch
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install nn || sudo -E $PREFIX/bin/luarocks install nn
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install dok || sudo -E $PREFIX/bin/luarocks install dok
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install gnuplot || sudo -E $PREFIX/bin/luarocks install gnuplot
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
[ -x "$cutorch" ] && \
($PREFIX/bin/luarocks install cutorch || sudo -E $PREFIX/bin/luarocks install cutorch || cutorch=failed )
[ -x "$cunn" ] && \
($PREFIX/bin/luarocks install cunn || sudo -E $PREFIX/bin/luarocks install cunn || cunn=failed )
$PREFIX/bin/luarocks install qtlua || sudo -E $PREFIX/bin/luarocks install qtlua
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install qttorch || sudo -E $PREFIX/bin/luarocks install qttorch
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install luafilesystem || sudo -E $PREFIX/bin/luarocks install luafilesystem
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install penlight || sudo -E $PREFIX/bin/luarocks install penlight
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install sys || sudo -E $PREFIX/bin/luarocks install sys
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install xlua || sudo -E $PREFIX/bin/luarocks install xlua
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install image || sudo -E $PREFIX/bin/luarocks install image
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install optim || sudo -E $PREFIX/bin/luarocks install optim
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install lua-cjson || sudo -E $PREFIX/bin/luarocks install lua-cjson
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
$PREFIX/bin/luarocks install trepl || sudo -E $PREFIX/bin/luarocks install trepl
RET=$?; if [ $RET -ne 0 ]; then echo "Error. Exiting."; exit $RET; fi
# Done.
echo ""
echo "=> Torch7 has been installed successfully"
echo ""
echo " + Extra packages have been installed as well:"
echo " $ luarocks list"
echo ""
echo " + To install more packages, do:"
echo " $ luarocks search --all"
echo " $ luarocks install PKG_NAME"
echo ""
echo " + Note: on MacOS, it's a good idea to install GCC 4.9 to enable OpenMP."
echo " You can do this by with brew"
echo " $ brew tap homebrew/versions"
echo " $ brew install gcc49"
echo " then edit ~/.profile with the lines"
echo " export CC=gcc-4.9"
echo " export CXX=g++-4.9"
echo " and make sure you load the new environmental variables into your session"
echo " $ source ~/.profile"
echo ""
echo " + packages installed:"
echo " - sundown "
echo " - cwrap "
echo " - paths "
echo " - torch "
echo " - nn "
echo " - dok "
echo " - gnuplot "
[ -x "$cutorch" ] && echo " - cutorch : " $cutorch
[ -x "$cunn" ] && echo " - cunn : " $cunn
echo " - qtlua "
echo " - qttorch "
echo " - lfs "
echo " - penlight "
echo " - sys "
echo " - xlua "
echo " - image "
echo " - optim "
echo " - cjson "
echo " - trepl "
echo ""