-
Notifications
You must be signed in to change notification settings - Fork 225
/
CMakePreBuild.sh
135 lines (105 loc) · 4.33 KB
/
CMakePreBuild.sh
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
#!/usr/bin/env bash
# this script is automatically run from CMakeLists.txt
BUILD_ROOT=$PWD
TORCH_PREFIX=$PWD/torch
echo "[Pre-build] dependency installer script running..."
echo "[Pre-build] build root directory: $BUILD_ROOT"
echo "[Pre-build] installing Torch/LUA into: $TORCH_PREFIX"
# break on errors
set -e
# Install dependencies for Torch:
echo "[Pre-build] installing Torch7 package dependencies"
sudo apt-get update
sudo apt-get install -y gfortran build-essential gcc g++ cmake curl libreadline-dev git-core liblua5.1-0-dev
# note: gfortran is for OpenBLAS LAPACK compilation
##sudo apt-get install -qqy libgd-dev
sudo apt-get update
echo "[Pre-build] Torch7's package dependencies have been installed"
# Install openBLAS
echo "[Pre-build] build OpenBLAS? $1"
if [ $1 = "ON" ] || [ $1 = "YES" ] || [ $1 = "Y" ]; then
echo "[Pre-build] building OpenBLAS...";
rm -rf OpenBLAS
git clone http://github.org/xianyi/OpenBLAS
cd OpenBLAS
mkdir build
make
make install PREFIX=$BUILD_ROOT/OpenBLAS/build
export CMAKE_LIBRARY_PATH=$BUILD_ROOT/OpenBLAS/build/include:$BUILD_ROOT/OpenBLAS/build/lib:$CMAKE_LIBRARY_PATH
cd $BUILD_ROOT
fi
# Install luajit-rocks into Torch dir
echo "[Pre-build] configuring luajit-rocks"
cd $BUILD_ROOT
rm -rf luajit-rocks
git clone https://github.com/torch/luajit-rocks.git
cd luajit-rocks
mkdir -p build
cd build
git checkout master; git pull
rm -f CMakeCache.txt
cmake .. -DWITH_LUAJIT21=yes -DCMAKE_INSTALL_PREFIX=$TORCH_PREFIX -DCMAKE_BUILD_TYPE=Release
make
make install
cd $BUILD_ROOT
path_to_nvcc=$(which nvcc)
if [ -x "$path_to_nvcc" ]
then
cutorch=ok
cunn=ok
echo "[Pre-build] detected NVCC / CUDA toolkit"
fi
sudo apt-get install gnuplot gnuplot-qt
# Install base packages:
echo "[Pre-build] installing luarocks packages"
cd $BUILD_ROOT
git clone http://github.com/torch/rocks
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/luaffi-scm-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/cwrap-scm-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/paths-scm-1.rockspec
#$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/torch-scm-1.rockspec
cd $BUILD_ROOT
git clone http://github.com/torch/torch7
cd torch7
git checkout 7bbe17917ea560facdc652520e5ea01692e460d3
$TORCH_PREFIX/bin/luarocks make $BUILD_ROOT/torch7/rocks/torch-scm-1.rockspec
cd $BUILD_ROOT
#sed -i 's/neon/asimd/g' torch7/lib/TH/cmake/FindARM.cmake
#sed -i 's/STRING(COMPARE EQUAL "neon" "${NEON_THERE}" NEON_TRUE)/set(NEON_TRUE TRUE)/g' torch7/lib/TH/cmake/FindARM.cmake
#$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/torch7/rocks/torch-scm-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/nn-scm-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/nnx-0.1-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/optim-1.0.5-0.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/rocks/gnuplot-scm-1.rockspec
#$TORCH_PREFIX/bin/luarocks install cwrap
#$TORCH_PREFIX/bin/luarocks install paths
#$TORCH_PREFIX/bin/luarocks install torch
#$TORCH_PREFIX/bin/luarocks install nn
#$TORCH_PREFIX/bin/luarocks install nnx
#$TORCH_PREFIX/bin/luarocks install optim
#$TORCH_PREFIX/bin/luarocks install cutorch
#$TORCH_PREFIX/bin/luarocks install trepl
#$TORCH_PREFIX/bin/luarocks install gnuplot
git clone https://github.com/torch/cutorch
sed -i 's/$(getconf _NPROCESSORS_ONLN)/1/g' cutorch/rocks/cutorch-1.0-0.rockspec
sed -i 's/$(getconf _NPROCESSORS_ONLN)/1/g' cutorch/rocks/cutorch-scm-1.rockspec
sed -i 's/jopts=3/jopts=1/g' cutorch/rocks/cutorch-1.0-0.rockspec
sed -i 's/jopts=3/jopts=1/g' cutorch/rocks/cutorch-scm-1.rockspec
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/cutorch/rocks/cutorch-scm-1.rockspec
# install cudnn v5 bindings
#git clone -b R5 http://github.com/soumith/cudnn.torch
git clone http://github.com/soumith/cudnn.torch
#sed -i 's/ffi.sizeof('half'),/2,/g' cudnn.torch/init.lua
$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/cudnn.torch/cudnn-scm-1.rockspec
echo ""
echo "[Pre-build] Torch7 has been installed successfully"
echo ""
#echo "installing iTorch"
#sudo apt-get install libzmq3-dev libssl-dev python-zmq
#sudo pip install ipython
#ipython --version
## pip uninstall IPython
## pip install ipython==3.2.1
#sudo pip install jupyter
#git clone https://github.com/facebook/iTorch.git
#$TORCH_PREFIX/bin/luarocks install $BUILD_ROOT/iTorch/itorch-scm-1.rockspec