Guest User

3dmm_cnn installation script, v. 2

a guest
Jun 9th, 2018
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.13 KB | None | 0 0
  1. # Original repository source: https://github.com/anhttran/3dmm_cnn
  2. #
  3. # Installation instructions:
  4. # 1. download the repository with model files included
  5. #    (or download/recreate model files, as described on the repository home page)
  6. # 2. download and install CUDA for Ubuntu 16.04:
  7. #    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
  8. #    sudo dpkg -i cuda-repo-ubuntu1604_9.2.88-1_amd64.deb
  9. #    sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
  10. #    sudo apt-get update
  11. #    sudo apt-get install cuda
  12. # 3. Do
  13. #    conda create -n=3dmm_cnn python=2.7.*
  14. #    source activate 3dmm_cnn
  15. # 4. Then
  16. #    bash install.sh
  17.  
  18. # Following this guide to install Caffe: https://yangcha.github.io/Caffe-Conda/
  19.  
  20. ENV_NAME="3dmm_cnn"
  21. echo "The script installs the library and all its requirements in a separate virtual environment ($ENV_NAME)"
  22.  
  23. #echo "------------- Updating Conda -------------"
  24. #conda update
  25.  
  26. echo "------------- Ubuntu packages -------------"
  27. echo "------------- (requires sudo) -------------"
  28.  
  29. sudo apt-get update
  30.  
  31. # for 3dmm_cnn:
  32. sudo apt install cmake libboost-all-dev freeglut3-dev libglew-dev libhdf5-dev
  33. # for Caffe:
  34. sudo apt-get install -y build-essential cmake git pkg-config libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler libatlas-base-dev libgflags-dev libgoogle-glog-dev liblmdb-dev
  35. sudo apt-get install -y --no-install-recommends libboost-all-dev
  36.  
  37. echo "------------- Conda packages -------------"
  38. conda install numpy cython scikit-image ipython h5py nose pandas protobuf pyyaml jupyter scikit-image pillow
  39.     # first two for 3dmm_cnn, others for Caffe
  40. # the following might be needed:
  41. #conda install msgpack
  42. #conda install python-dateutil
  43. pip install dlib
  44.  
  45. echo "------------- OpenCV -------------"
  46. conda install -c menpo opencv3
  47.  
  48. echo "------------- Dlib C++ library -------------"
  49. tar xvf dlib-19.13.tar.bz2
  50. mv dlib-19.13 dlib
  51. cd dlib
  52. mkdir build
  53. cd build
  54. cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=../bin ..
  55. make clean
  56. sudo ldconfig
  57. make
  58. make install
  59.  
  60. echo "------------- Caffe  -------------"
  61. cd ../..    # returning to 3dmm_cnn home dir
  62. git clone https://github.com/BVLC/caffe.git
  63. cd caffe
  64. mkdir build
  65. cd build
  66. echo "---- Building Caffe ----"
  67. cmake ..
  68. make all
  69. make install
  70. echo "---- Installing pip dependencies for Caffe ----"
  71. cd ../python
  72. for req in $(cat requirements.txt); do pip install $req; done
  73. echo "---- Building Python bindings for Caffe ----"
  74. cd ../build
  75. make runtest
  76. cd ../python
  77. export PYTHONPATH=`pwd`${PYTHONPATH:+:${PYTHONPATH}}
  78. echo "export PYTHONPATH=`pwd`${PYTHONPATH:+:${PYTHONPATH}}" >> ~/.bashrc
  79.  
  80. echo "---- Verifying Caffe works ----"
  81. echo "---- (the Caffe version should be printed below, if everything is OK) ----"
  82. CUDA_DEVICE=0
  83. CUDA_VISIBLE_DEVICES=$CUDA_DEVICE python -c "import caffe;print caffe.__version__"
  84.  
  85.  
  86.  
  87. # ----------------
  88. # Running:
  89. #cd $3DMM_CNN_DIR
  90. #cd demoCode
  91. #CUDA_VISIBLE_DEVICES=$CUDA_DEVICE python testBatchModel.py input.txt output 1    # where $CUDA_DEVICES is e.g. 0
Advertisement
Add Comment
Please, Sign In to add comment