Last active
February 4, 2017 19:08
-
-
Save raibread/4448483 to your computer and use it in GitHub Desktop.
This is a oneline torch7 installation script (including dependencies) for macosx --
Adapted from: https://github.com/clementfarabet/torchinstall/blob/master/install
-- It has been tested in parts but not as a whole.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################################################################# | |
# This script installls Torch7 and it's various dependencies. | |
# | |
# The script is adapted from: | |
# https://github.com/clementfarabet/torchinstall/blob/master/install | |
# | |
# The above didn't quite work for me on macosx (10.8.2) so the following adjustments were made: | |
# (1) install gcc 4.7.2 and set as compilers used in Torch build so open OpenMP works | |
# (2) brew install a previous version of zeromq (2.2) since Torch7 doesn't play well | |
# with the version 3.2 yet | |
# (3) install xquartz package since X11 is no longer included with macosx >= 10.8 | |
# (4) update luarocks config file so macosx defaults.variables.MAKE="make" not | |
# "gmake" -- This was changed in the luarocks development code (see: | |
# https://github.com/keplerproject/luarocks/commit/73ddf616ba5b9e14979a4ab8f16702d2d502098c) | |
# but isn't reflected in the 2.0.12 release (which is the release that | |
# the homebrew formula uses) | |
# | |
# | |
# NOTE: I removed the Linux option since I'm not running any Linux machines right now | |
################################################################################################# | |
if [[ `uname` == 'Darwin' ]]; then | |
# Install Homebrew (pkg manager): | |
if [[ `which brew` == '' ]]; then | |
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) | |
fi | |
# Install git: | |
brew install git | |
# Install gcc (4.7.2 -- necessary for OpenMP functionality of Torch): | |
brew install --enable-gxx --enable-fortran https://raw.github.com/Homebrew/homebrew-dupes/master/gcc.rb | |
# install other dependencies: | |
brew install readline cmake wget qt | |
brew install libjpeg imagemagick | |
# zeromq 3.x doesn't work with Torch yet -- use 2.2 (brew versions zeromq will provide the zeromq 2.2 checkout): | |
git checkout 6a2e6ef /usr/local/Library/Formula/zeromq.rb | |
brew install zeromq | |
# install gnuplot: | |
if [[ `which X` == '' ]]; then | |
echo 'downloading X11' | |
curl http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.4.dmg > ~/xquartz.dmg | |
echo 'mounting X11 disk image' | |
hdiutil ~/xquart.dmg | |
echo 'installing xquartz' | |
sudo installer -verbose -pkg "/Volumes/XQuartz-2.7.4/XQuartz.pkg" -target / | |
hdiutil detach /Volumes/XQuartz-2.7.4 | |
if [[ `which X` == '' ]]; then | |
echo 'error installing xquartz package, aborting...' | |
exit | |
fi | |
fi | |
brew install gnuplot | |
# install lua and luarocks (lua package manager) | |
brew install lua luarocks | |
# macosx uses make not gmake like other BSDs | |
if [[ $(awk -v w=0 '/if detected.macosx then/, /^\s*end\s*/ {if ($0 ~ /defaults\.variables\.MAKE[ *]=[ *]"make"/) w += 1} | |
END {print w}' /usr/local/Cellar/luarocks/2.0.12/share/lua/5.1/luarocks/cfg.lua) == 0 ]]; then | |
sed 's/if[ *]detected\.macosx[ *]then/if detected\.macosx then\ | |
defaults.variables.MAKE = "make"/' /usr/local/Cellar/luarocks/2.0.12/share/lua/5.1/luarocks/cfg.lua > TEMPcfg.lua | |
mv TEMPcfg.lua /usr/local/Cellar/luarocks/2.0.12/share/lua/5.1/luarocks/cfg.lua | |
fi | |
# Use more recent gcc (>=4.6) to compile Torch, etc. | |
export CC=/usr/local/Cellar/gcc/4.7.2/bin/gcc-4.7 | |
export CXX=/usr/local/Cellar/gcc/4.7.2/bin/g++-4.7 | |
# Create custom config file for Luarocks | |
mkdir -p ~/.luarocks | |
echo "rocks_servers = {" > ~/.luarocks/config.lua | |
echo " [[http://luarocks.org/repositories/rocks]]," >> ~/.luarocks/config.lua | |
echo " [[http://data.neuflow.org/luarocks]]," >> ~/.luarocks/config.lua | |
echo "}" >> ~/.luarocks/config.lua | |
echo "rocks_trees = {" >> ~/.luarocks/config.lua | |
echo " home..[[/.luarocks]]," >> ~/.luarocks/config.lua | |
echo " [[/usr/local]]" >> ~/.luarocks/config.lua | |
echo "}" >> ~/.luarocks/config.lua | |
# Install Torch7, with LuaJIT support, and extra packages | |
luarocks install torch WITH_LUA_JIT=1 | |
luarocks install penlight | |
luarocks install image | |
luarocks install parallel | |
luarocks install optim | |
luarocks install json | |
else | |
# Unsupported | |
echo '==> platform not supported, aborting' | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment