Last active
March 9, 2017 22:02
-
-
Save byelipk/9f89e19473373c746c84407fb0f03341 to your computer and use it in GitHub Desktop.
Run this file to set up a fresh Ubuntu install ready for deep learning and computer vision
This file contains hidden or 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
cd ~ | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install build-essential cmake pkg-config git unzip libcurl3-dev | |
# Set up GPU support | |
# 1. Install CUDA: This is a set of drivers for your GPU that allows it to run a low-level programming language for parallel computing. | |
# 2. Install CuDNN: This is a library of highly optimized primitives for deep learning. | |
################ | |
##### CUDA ##### | |
################ | |
# NOTE | |
# I'm frequently running into login loops. The most likely cause of this are the Nvidia drivers. | |
# Possible fixes are listed here: | |
# http://askubuntu.com/questions/760934/graphics-issues-after-while-installing-ubuntu-16-04-16-10-with-nvidia-graphics | |
# | |
# Log into your account in the TTY. | |
# Run sudo apt-get purge nvidia-* | |
# Run sudo add-apt-repository ppa:graphics-drivers/ppa and then sudo apt-get update. | |
# Run sudo apt-get install nvidia-375. | |
# Reboot and your graphics issue should be fixed. | |
# Download CUDA | |
mkdir cuda_installers | |
wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda_8.0.44_linux-run | |
sudo sh cuda_8.0.44_linux-run -extract=./cuda_installers | |
# Install CUDA | |
cd cuda_installers | |
# Hit CTRL+ALT+F1 and login using your credentials | |
sudo service lightdm stop | |
sudo init 3 | |
# Run the CUDA installers in order | |
sudo ./NVIDIA-Linux-x86_64-367.48.run | |
modprobe nvidia | |
sudo ./cuda-linux64-rel-8.0.44-21122537.run | |
sudo ./cuda-samples-linux-8.0.44-21122537.run | |
# Configure environment variables | |
# Make sure there is a cuda-8.0 folder in /usr/local | |
echo 'export CUDA_HOME=/usr/local/cuda-8.0' >> ~/.bashrc | |
echo 'LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc | |
echo 'PATH=${CUDA_HOME}/bin:${PATH}' >> ~/.bashrc | |
source ~/.bashrc | |
# Test the CUDA Installation | |
cd /usr/local/cuda/samples | |
make | |
# After `make` has finished run `deviceQuery` to make sure CUDA and your GPU are on the same page. | |
# It should print out your GPU's specs. | |
cd /usr/local/cuda/samples/bin/x86_64/linux/release | |
./deviceQuery | |
################# | |
##### CuDNN ##### | |
################# | |
# Download dependencies for deep learning | |
sudo apt-get install libatlas-base-dev gfortran liblapack-dev libhdf5-serial-dev libopenblas-dev | |
# Install CuDNN from https://developer.nvidia.com/rdp/cudnn-download | |
# NOTE: Will need an Nvidia account! | |
mkdir cudnn_installers | |
tar -zxf cudnn-8.0-linux-x64-v5.1.tgz -C ./cudnn_installers | |
cd cudnn_installers/cuda | |
sudo cp lib64/* /usr/local/cuda-8.0/lib64/ | |
sudo cp include/* /usr/local/cuda-8.0/include/ | |
############################### | |
##### pyenv && virtualenv ##### | |
############################### | |
# Install pyenv | |
git clone https://github.com/yyuu/pyenv.git ~/.pyenv | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile | |
# Install pyenv-virtualenv | |
git clone https://github.com/yyuu/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv | |
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc | |
exec "$SHELL" | |
# Create a virtual environment for deep learning | |
pyenv install 3.5.0 | |
pyenv virtualenv 3.5.0 tensorflow | |
pyenv activate tensorflow | |
pip install --upgrade pip | |
pip install numpy scipy matplotlib pydot-ng pandas scikit-learn scikit-image mahotas | |
sudo apt-get install graphviz | |
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-0.12.1-cp35-cp35m-linux_x86_64.whl | |
pip install --upgrade $TF_BINARY_URL | |
# Create a virtual environment for computer vision | |
pyenv virtualenv 3.5.0 opencv3 | |
pyenv activate opencv3 | |
pip install numpy matplotlib scikit-learn scikit-image mahotas | |
################## | |
##### OpenCV ##### | |
################## | |
# Download dependencies for computer vision | |
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev | |
sudo apt-get install libxvidcore-dev libx264-dev | |
sudo apt-get install libgtk-3-dev | |
sudo apt-get install libgtk2.0-dev | |
# Download OpenCV | |
cd ~ | |
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip | |
unzip opencv.zip | |
# Download additional computer vision algorithms | |
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip | |
unzip opencv_contrib.zip | |
# NOTE | |
# Encountered an issue where we couldn't build OpenCV3 because the file libGL.so | |
# could not be found. This file is part of the Nvidia drivers. The solution is | |
# detailed in the URL below. It required fixing a symlink. | |
# | |
# See: http://techtidings.blogspot.com/2012/01/problem-with-libglso-on-64-bit-ubuntu.html | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \ | |
-D BUILD_opencv_python2=OFF \ | |
-D BUILD_opencv_python3=ON \ | |
-D BUILD_opencv_java=OFF \ | |
-D BUILD_TIFF=ON \ | |
-D WITH_CUDA=ON \ | |
-D WITH_CUBLAS=ON \ | |
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \ | |
-D ENABLE_FAST_MATH=1 \ | |
-D CUDA_FAST_MATH=1 \ | |
-D WITH_QT=ON \ | |
-D ENABLE_AVX=ON \ | |
-D WITH_OPENGL=ON \ | |
-D WITH_OPENCL=OFF \ | |
-D WITH_IPP=OFF \ | |
-D WITH_TBB=ON \ | |
-D WITH_EIGEN=ON \ | |
-D WITH_V4L=OFF \ | |
-D WITH_VTK=OFF \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D PYTHON3_LIBRARY=$(python -c "import re, os.path; print(os.path.normpath(os.path.join(os.path.dirname(re.__file__), '..', 'libpython3.6m.dylib')))") \ | |
-D PYTHON3_EXECUTABLE=$(which python) \ | |
-D PYTHON3_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \ | |
-D PYTHON3_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \ | |
-D BUILD_EXAMPLES=ON ../ \ | |
make -j8 | |
make install | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment