Skip to content

Instantly share code, notes, and snippets.

@avtomaton
Last active June 17, 2020 21:10
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save avtomaton/e410fc17b5e0b17735a2 to your computer and use it in GitHub Desktop.
Save avtomaton/e410fc17b5e0b17735a2 to your computer and use it in GitHub Desktop.
amazon AMI CUDA setup
#!/bin/bash
NVIDIA_DRIVER_VERSION=352.63
NVIDIA_CUDA_VERSION=7.5
NVIDIA_CUDA_FULL_VERSION=7.5.18
sudo yum update -y
sudo yum groupinstall -y "Development tools"
sudo yum install kernel-devel-`uname -r`
# add PATH for current user to sudo
echo "alias sudo='sudo env PATH=\$PATH'" >> ~/.bashrc
source ~/.bashrc
sudo yum install python34-devel python34-pip protobuf-devel boost-devel yasm
sudo yum install snappy-devel
sudo pip-3.4 install --upgrade pip
sudo pip-3.4 install numpy
# install NVIDIA driver
mkdir -p sdk
cd sdk
# latest cmake
https://cmake.org/files/v3.4/cmake-3.4.2.tar.gz
tar -zxvf cmake-3.4.2.tar.gz
cd cmake-3.4.2
./configure
make && sudo make install
cd ..
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/$NVIDIA_DRIVER_VERSION/NVIDIA-Linux-x86_64-$NVIDIA_DRIVER_VERSION.run
chmod a+x NVIDIA-Linux-x86_64-$NVIDIA_DRIVER_VERSION.run
sudo ./NVIDIA-Linux-x86_64-$NVIDIA_DRIVER_VERSION.run
# install NVIDIA CUDA
wget http://developer.download.nvidia.com/compute/cuda/$NVIDIA_CUDA_VERSION/Prod/local_installers/cuda_$NVIDIA_CUDA_FULL_VERSION_linux.run
chmod a+x cuda_$NVIDIA_CUDA_FULL_VERSION_linux.run
./cuda_$NVIDIA_CUDA_FULL_VERSION_linux.run
# ffmpeg
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
./configure --enable-shared --disable-static
make -sj7 && sudo make install
cd ..
# opencv
git clone https://github.com/Itseez/opencv.git
cd opencv
mkdir build && cd build
cmake ..
cd ../..
# gflags
git clone https://github.com/gflags/gflags.git
cd gflags
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake .. && make
sudo make install
cd ../..
# glog
git clone https://github.com/google/glog
cd glog
mkdir build && cd build
export CXXFLAGS="-fPIC" && cmake .. && make
sudo make install
cd ../..
# lmdb
git clone https://github.com/LMDB/lmdb.git
cd lmdb/libraries/liblmdb
make
sudo make install
cd ../../..
# leveldb
git clone https://github.com/google/leveldb.git
cd leveldb
make
sudo cp *.so* /usr/local/lib
sudo cp *.so* /usr/local/lib
sudo cp -r include/leveldb /usr/local/include
echo -e $'#!/bin/bash\n\nsudo rm -f /usr/local/lib/leveldb*\nsudo rm -rf /usr/local/include/leveldb\n' > uninstall.sh
chmod a+x uninstall.sh
cd ..
# hdf5
wget http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.16.tar
tar -xvf hdf4-1.8.16.tar
cd hdf4-1.8.16
mkdir build && cd build
cmake .. && make
sudo make install
# copy includes/libs to proper locations
# fix libraries list in Dependencies.cmake (add hdf5-shared and hdf5_hl-shared)
cd ../..
# and here should be patch for caffe dependencies (FindHDF5.cmake or Dependencies.cmake)
# atlas
wget http://downloads.sourceforge.net/project/math-atlas/Stable/3.10.2/atlas3.10.2.tar.bz2
tar -jxvf atlas3.10.2.tar.bz2
mv ATLAS atlas-3.10
cd atlas-3.10
mkdir buld && cd build
../configure && make
sudo make install
cd ../..
export Atlas_ROOT_DIR=/usr/local/atlas
# patch FindAtlas.cmake: add 'lapack' to Atlas_LAPACK_LIBRARY
# openblas (incomplete)
# git clone https://github.com/xianyi/OpenBLAS.git
# cd OpenBlas
# mkdir build && cd build
# cmake ..
# caffe
git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build && cd build
# disable python module for now
# because default boost version on amazon AWS doesn't support python3
# TODO: compile boost separately instead of using default one
cmake -DBUILD_python=OFF .. && make
sudo make install
cd ../..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment