わたしのかんきょうこうちく[WIP]

## update
```bash
sudo apt-get update && sudo apt-get upgrade -y
```

## zsh
```bash
sudo apt-get install zsh
which zsh
chsh
```

## git
```bash
sudo apt-get install -y git
```

## oh-my-zsh
```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" ~
```

## byobu
```bash
sudo apt-get install -y byobu
```

## vim
```bash
sudo apt-get install -y vim
```

## NVIDIA Driver install
###  check if there's old driver
```bash
dpkg -l | grep nvidia
dpkg -l | grep cuda
```
### if there's old driver, delete them
```bash
sudo apt-get --purge remove nvidia-*
sudo apt-get --purge remove cuda-*
```
### register repository
```bash
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
```
### search driver
```bash
apt search nvidia > result.txt
cat result.txt | grep -E 'nvidia-[0-9][0-9][0-9]\/'
```
### install driver
```bash
sudo apt-get install nvidia-384
```
### reboot
```bash
sudo reboot
```
### confirmation
check if there's your device on the command output
```bash
nvidia-smi
```

## cuda installation
get installer from here: https://developer.nvidia.com/cuda-downloads
follow the instruction in the link
```
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
```

### add .zshrc below
```
echo -e "\n## CUDA and cuDNN paths"  >> ~/.zshrc
echo 'export PATH=/usr/local/cuda-8.0/bin:${PATH}' >> ~/.zshrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:${LD_LIBRARY_PATH}' >> ~/.zshrc
source ~/.zshrc
```

## cuDNN Install
### (via Deb)
download package from https://developer.nvidia.com/rdp/cudnn-download
```
# Install Runtime library
sudo dpkg -i libcudnn6_6.0*+cuda8.0_amd64.deb
# Install developer library
sudo dpkg -i libcudnn6-dev_6.0*+cuda8.0_amd64.deb
# Install code samples and user guide
sudo dpkg -i libcudnn6-doc_6.0*+cuda8.0_amd64.deb
```

### (Manually)
```
tar xzvf cudnn-8.0-linux-x64-v5.1.tgz 
sudo cp -a cuda/lib64/* /usr/local/cuda-8.0/lib64/
sudo cp -a cuda/include/* /usr/local/cuda-8.0/include/
sudo ldconfig
```

### cuDNN UnInstall (if you installed manually, when you want to upgrade cuDNN)
```bash
cd /usr/local/cuda-8.0/lib64/
sudo rm libcudnn.so  libcudnn.so.5  libcudnn.so.5.1.5  libcudnn_static.a
cd /usr/local/cuda-8.0/include/
sudo rm cudnn.h
sudo ldconfig
```

### For cuDNN Installation Testing
```bash
cuda-install-samples-8.0.sh ~ # ホームディレクトリにサンプルコードをコピー。
cd ~/NVIDIA_CUDA-8.0_Samples/
make
cd bin/x86_64/linux/release   # サンプルの実行ファイルがあるディレクトリに移動。
./smokeParticles
```

## Install Python and other dependencies

### Prerequirement

```bash
sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev
```

### Pyenv install
```bash
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc
```

### pyenv-virtualenv install

```bash
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
```
### anaconda install
```bash
pyenv install -l | grep anaconda3
# 最新版を確認。anaconda3-2.5.0 (2系はanaconda-2.5.0)
# minicondaがいい人はminicondaを入れてください。
pyenv install anaconda3-4.4.0
pyenv rehash
pyenv global anaconda3-4.4.0
# anacondaをメインのpythonに設定。
echo 'export PATH="$PYENV_ROOT/versions/anaconda3-4.4.0/bin/:$PATH"' >> ~/.zshrc
source ~/.zshrc
# activateがpyenvとanacondaでバッティングするので、pathに明示しておく。
conda update conda
#念のためconda自体をアップデートしておく。
```

### OpenCV Install (PyPI)

```bash
pip install opencv-python
```

### OpenCV Install (Build)

スクリプト引用元：http://bfin.sakura.ne.jp/?p=967

```bash:install.sh
#! /bin/sh
# Setting the Ubuntu for open-CV
sudo apt-get -yV install cmake
sudo apt-get -yV install libeigen3-dev
# GUIフレームワーク関連
sudo apt-get -yV install libgtk2.0-dev
sudo apt-get -yV install libgtkglext1-dev
sudo apt-get -yV install libqt4-dev
sudo apt-get -yV install freeglut3-dev
# 並列処理関連
sudo apt-get -yV install opencl-headers
sudo apt-get -yV install libtbb-dev
# 画像フォーマット関連
sudo apt-get -yV install libjpeg-dev
sudo apt-get -yV install libjasper-dev
sudo apt-get -yV install libpng++-dev
sudo apt-get -yV install libtiff-dev
sudo apt-get -yV install libopenexr-dev
sudo apt-get -yV install libwebp-dev
# Python関連
sudo apt-get -yV install libpython3-dev
sudo apt-get -yV install python-numpy python-scipy python-matplotlib
sudo apt-get -yV install python3-numpy python3-scipy python3-matplotlib
# ホームへ移動
cd ~
# OpenCV の取得
wget https://github.com/opencv/opencv/archive/3.3.0.tar.gz
tar xvzf 3.3.0.tar.gz
cd opencv-3.3.0
# Build script for Open-CV 3
# CMAKE build environment setting in open-cv directory
SOURCE_DIR="echo $(cd $(dirname $0);pwd)"
BUILD_DIR=${SOURCE_DIR}/build
GENERATOR_NAME="Unix Makefiles"
mkdir build
cd build
cmake \
-G "${GENERATOR_NAME}" \
--build ${BUILD_DIR} \
-D BUILD_opencv_world=ON \
${SOURCE_DIR}
# make the library
make -j2
# install the library
sudo make install
# conifugre the dynamic links
sudo ldconfig
```

## TensorFlow Install
```bash
pip install tensorflow-gpu
```

## Chainer Install
```bash
pip install cupy
pip install chainer
```