It is a work memo until Keras (GPU version) and OpenCV 3.2 can be operated with Python 2.7.
https://developer.nvidia.com/rdp/cudnn-download
From "Download cuDNN v6.0 (April 27, 2017), for CUDA 8.0" You need to download "cuDNN v6.0 Library for Linux". (cuDNN v7.0 doesn't seem to be supported by TensorFlow 1.3.0 [^ 1])
Suppose you put the downloaded file in "/tmp/cudnn-8.0-linux-x64-v6.0.tgz".
How to install nvidia-docker
is described in the link below.
https://github.com/NVIDIA/nvidia-docker
nvidia-docker pull nvidia/cuda
nvidia-docker run -it -v /tmp:/tmp nvidia/cuda bash
apt-get update -y
apt-get upgrade -y
apt-get install -y python-dev python-setuptools curl
curl -kL https://bootstrap.pypa.io/get-pip.py | python
pip install tensorflow-gpu==1.3.0
tar -xvzf /tmp/cudnn-8.0-linux-x64-v6.0.tgz
mv cuda/lib64/libcudnn* /usr/local/cuda/lib64/
mv cuda/include/cudnn.h /usr/local/cuda/include/
chmod a+r /usr/local/cuda/include/cudnn.h
chmod a+r /usr/local/cuda/lib64/libcudnn*
echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64'" >> ~/.bashrc
echo "export CUDA_HOME=/usr/local/cuda" >> ~/.bashrc
source ~/.bashrc
pip install Keras==2.0.6
python -c "import keras; print(keras.__version__)"
If 2.0.6
is displayed, it is successful.
After that, all the work is done inside the Docker container. I refer to the article [^ 2].
apt-get install -y build-essential cmake git pkg-config libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk-3-dev libatlas-base-dev gfortran python2.7-dev zip libhdf5-dev libprotobuf-dev libprotoc-dev protobuf-compiler xserver-xorg doxygen wget
In the middle
Country of origin for the keyboard: 50
Keyboard layout: 1
Message will appear, so you need to select it according to your environment. In my case, I set it to 50 (Japanese) and 1 (Japanese).
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
unzip opencv.zip
cd opencv-3.2.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_CUDA_STUBS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_FFMPEG=OFF -D BUILD_opencv_python2=ON -D BUILD_EXAMPLES=OFF -DBUILD_opencv_dnn=OFF ..
make -j $(nproc)
make install
For options at cmake, the code [^ 3] will be helpful.
python -c "import cv2; print(cv2.__version__)"
If 3.2.0
is displayed in, it is successful.
References
Recommended Posts