Skip to content

Instantly share code, notes, and snippets.

@finder39
Last active August 9, 2016 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save finder39/ee409a5e2d0343d9171e6c41e2d84ffd to your computer and use it in GitHub Desktop.
Save finder39/ee409a5e2d0343d9171e6c41e2d84ffd to your computer and use it in GitHub Desktop.
crfasrnnDir="${HOME}/crfasrnn"
serverSetupDir="${HOME}/serverSetup"
# install git if not installed
if ! hash git 2>/dev/null; then
apt-get install -y git
fi
#install unzip if not installed
if ! hash unzip 2>/dev/null; then
apt-get install -y unzip
fi
# create the temp download directory
sudo -u $SUDO_USER mkdir -p ${serverSetupDir}
# download needed files
cd ${serverSetupDir}
if [ ! -f "viennacl_1.5.1.orig.tar.gz" ]; then
sudo -u $SUDO_USER wget "http://archive.ubuntu.com/ubuntu/pool/universe/v/viennacl/viennacl_1.5.1.orig.tar.gz"
fi
if [ ! -f "cuda-repo-ubuntu1404_7.5-18_amd64.deb" ]; then
sudo -u $SUDO_USER wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb"
fi
if [ ! -f "openblas_0.2.18.orig.tar.gz" ]; then
sudo -u $SUDO_USER wget "https://launchpad.net/ubuntu/+archive/primary/+files/openblas_0.2.18.orig.tar.gz"
fi
# unzip and install ViennaCL
cd ${serverSetupDir}
if [ ! -d "ViennaCL-1.5.1-src" ]; then
sudo -u $SUDO_USER tar -xvf viennacl_1.5.1.orig.tar.gz
fi
cd "ViennaCL-1.5.1-src"
cp -a viennacl/ /usr/local/include/
# unzip and install OpenBLAS
cd ${serverSetupDir}
if [ ! -d "OpenBLAS-0.2.18" ]; then
sudo -u $SUDO_USER tar -xvf openblas_0.2.18.orig.tar.gz
fi
if [ ! -d "/opt/openblas" ]; then
cd "OpenBLAS-0.2.18"
make
make PREFIX=/opt/openblas install
fi
cd ${HOME}
# install pip and Flask
apt-get install -y python-pip
pip install Flask
# install dependencies
# apt-get install -y libopencv-dev python-opencv
apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
apt-get install -y --no-install-recommends libboost-all-dev
apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
apt-get install -y libopenblas-dev
# # install opencv 3
# # from https://github.com/milq/scripts-ubuntu-debian/blob/master/install-opencv.sh
# apt-get -y update
# apt-get -y upgrade
# apt-get -y dist-upgrade
# apt-get -y autoremove
# # INSTALL THE DEPENDENCIES
# # Build tools:
# apt-get install -y build-essential cmake
# # GUI (if you want to use GTK instead of Qt, replace 'qt5-default' with 'libgtkglext1-dev' and remove '-DWITH_QT=ON' option in CMake):
# apt-get install -y qt5-default libvtk6-dev
# # Media I/O:
# apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev
# # Video I/O:
# apt-get install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev
# # Parallelism and linear algebra libraries:
# apt-get install -y libtbb-dev libeigen3-dev
# # Python:
# apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
# # Java:
# apt-get install -y ant default-jdk
# # INSTALL THE LIBRARY (YOU CAN CHANGE '3.1.0' FOR THE LAST STABLE VERSION)
# cd ${serverSetupDir}
# if [ ! -d "ViennaCL-1.5.1-src" ]; then
# sudo -u $SUDO_USER wget https://github.com/Itseez/opencv/archive/3.1.0.zip
# sudo -u $SUDO_USER unzip 3.1.0.zip
# sudo -u $SUDO_USER rm 3.1.0.zip
# sudo -u $SUDO_USER mv opencv-3.1.0 OpenCV
# cd OpenCV
# mkdir build
# cd build
# sudo -u $SUDO_USER cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..
# sudo -u $SUDO_USER make -j4
# sudo make install
# sudo -u $SUDO_USER ldconfig
# echo "opencv 3.0 installed"
# fi
# # purge existing Nvidea
# apt-get remove -y --purge nvidia*
#
# # install Nvidea CUDA
# dpkg -i ${serverSetupDir}/cuda-repo-ubuntu1404_7.5-18_amd64.deb
# apt-get update
# apt-get install -y cuda
#
# apt-get install -y freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
#
# cat <<EOT >> /etc/modprobe.d/blacklist.conf
#
# # NVidea CUDA blacklist
# blacklist amd76x_edac
# blacklist vga16fb
# blacklist nouveau
# blacklist rivafb
# blacklist nvidiafb
# blacklist rivatv
#
# EOT
# more python stuff
apt-get install -y python-dev
apt-get install -y python-numpy
apt-get install -y boost-python
apt-get install -y python-scipy
pip install pandas
pip install image
pip install spicy
pip install cython
pip install scikit-image
pip install protobuf
# maybe these? https://github.com/NVIDIA/DIGITS/issues/187
yes | pip uninstall matplotlib
apt-get install -y libfreetype6 libfreetype6-dev
apt-get install -y libxft-dev
apt-get install -y python-matplotlib
pip install matplotlib
# create main directory
sudo -u $SUDO_USER mkdir -p ${crfrnnDir}
# install OpenBLAS
apt-get install -y OpenBLAS
# clone CRF-RNN
cd ${HOME}
sudo -u $SUDO_USER git clone --recursive https://github.com/torrvision/crfasrnn.git
# install python dependencies
cd ${crfrnnDir}/caffe/python
for req in $(cat requirements.txt); do pip install $req; done
# make caffe
cd ${crfasrnnDir}/caffe
sudo -u $SUDO_USER wget -O "Makefile.config" "https://gist.githubusercontent.com/finder39/1ae3c29241b3f9d4957d97a327af3f25/raw"
sudo -u $SUDO_USER make clean
sudo -u $SUDO_USER make
sudo -u $SUDO_USER make pycaffe
# setup mythonpath thing
sudo -u $SUDO_USER export PYTHONPATH=~/crfasrnn/caffe/python:$PYTHONPATH
# download trained model
cd ${crfasrnnDir}/python-scripts
if [ ! -f "TVG_CRFRNN_COCO_VOC.caffemodel" ]; then
./download_trained_model.sh
mv TVG_CRFRNN_COCO_VOC.caffemodel old_TVG_CRFRNN_COCO_VOC.caffemodel
${crfasrnnDir}/caffe/build/tools/upgrade_net_proto_binary ${crfasrnnDir}/python-scripts/old_TVG_CRFRNN_COCO_VOC.caffemodel ${crfasrnnDir}/python-scripts/TVG_CRFRNN_COCO_VOC.caffemodel
fi
# configure matplotlib without a GUI
perl -pi -e 's/backend : TkAgg/backend : Agg/g' /etc/matplotlibrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment