Skip to content

Instantly share code, notes, and snippets.

@c9s c9s/debian-8-opencv-gpu
Last active Sep 26, 2017

Embed
What would you like to do?
This script allows you to install Nvidia CUDA 8 and OpenCV with GPU support
#!/bin/bash
# update the base system packages
apt-get update && apt-get upgrade -y
# Update source list for cuda and python3.6
cat <<ENDLIST >> /etc/apt/sources.list
# non-free to nvidia-cuda-toolkit
deb http://ftp.de.debian.org/debian stretch non-free
deb http://ftp.de.debian.org/debian stretch contrib
# experimental for python3.6
deb http://ftp.de.debian.org/debian experimental main
deb http://ftp.de.debian.org/debian unstable main
ENDLIST
echo 'APT::Default-Release "stable";' | sudo tee -a /etc/apt/apt.conf.d/00local
apt-get update && apt-get upgrade -y
apt-get -t experimental install -y cmake golang-1.8 build-essential git wget unzip yasm pkg-config \
libswscale-dev \
libeigen3-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libavformat-dev \
libpng-dev \
libtiff-dev \
libpq-dev \
python3.6 python3.6-dev libboost-python1.63-dev
# unsupported GNU version! gcc versions later than 5 are not supported by CUDA
# -D CMAKE_C_COMPILER=/usr/bin/gcc-5
# -D CMAKE_CXX_COMPILER=/usr/bin/g++-5
apt-get install -y gcc-5 g++-5
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 1
# python3-pip doesn't depends on python3.6, it depends on all python >= 3.4
apt-get install -y python3-pip
pip3 install numpy
pip3 install scipy
# install nvidia-cuda
apt-get install -y nvidia-cuda-toolkit
cat <<ENDLIST >> /etc/profile.d/cuda
export CUDA_HOME=/usr/lib/nvidia-cuda-toolkit
export PATH=\$PATH:\$CUDA_HOME/bin
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$CUDA_HOME/lib64
ENDLIST
source /etc/profile.d/cuda
rm -f build-python3
curl -O https://raw.githubusercontent.com/c9s/opencv.dockerfile/master/build-python3
bash build-python3
# install docker
# curl -sSL https://get.docker.com/ | sh
# usermod -aG docker c9s
# https://medium.com/google-cloud/jupyter-tensorflow-nvidia-gpu-docker-google-compute-engine-4a146f085f17
# install nvidia docker
wget https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i nvidia-docker*.deb
sudo nvidia-docker run --rm nvidia/cuda nvidia-smi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.