Nvidia GT1070

From The World according to Vissie
Jump to navigation Jump to search

Cuda 10.0

This worked for me:

https://elec-otago.blogspot.com/2019/05/installing-tensorflow-and-cuda-10-on.html
sudo apt-get install linux-headers-$(uname -r | sed 's/[^-]*-[^-]*-//')
sudo apt-get install dkms

Enable backports

deb http://deb.debian.org/debian buster-backports main non-free contrib 
sudo apt update
  1. nvidia-driver 450.66
sudo apt-get -t buster-backports install nvidia-driver nvidia-smi

reboot

wget from

https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal
wget wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64
mv ./cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64 ./cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb


dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-key adv --fetch-keys 
http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1704/x86_64/7fa2af80.pub
sudo apt update
sudo apt install cuda-libraries-10-0
sudo apt install cuda-toolkit-10-0
sudo apt install -t buster-backports libcuda1

wget from

http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/
dpkg -i libcudnn7_7.6.0.64-1+cuda10.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7-dev_7.6.0.64-1+cuda10.0_amd64.deb
sudo dpkg -i ./libcudnn7-dev_7.6.0.64-1+cuda10.0_amd64.deb 
sudo pip3 install --upgrade setuptools 
sudo pip3 install tensorflow-gpu

Install Debian 10

wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-debian10-11-1- local_11.1.1-455.32.00-1_amd64.deb 
sudo dpkg -i cuda-repo-debian10-11-1-local_11.1.1-455.32.00-1_amd64.deb
sudo apt-get install software-properties-common
sudo add-apt-repository contrib
sudo apt-get update
# read what is says on the screen. Should be something like
sudo apt-key add /var/cuda-repo-debian10-11-1-local/7fa2af80.pub
sudo apt-get -y install cuda

reboot

Install Tensorflow

pip uninstall tensorflow
pip install tensorflow-gpu

Compile opencv

pre-prep

It seems that one must compile opencv from source. I'll give it a go:

https://www.pyimagesearch.com/2020/02/03/how-to-use-opencvs-dnn-module-with-nvidia-gpus-cuda-and-cudnn/
sudo apt-get install build-essential cmake unzip pkg-config libjpeg-dev libpng-dev libtiff-dev libavcodec-dev libavformat-dev libswscale-dev

I could not install libgtk-3-dev, so left it out.

sudo apt-get install libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev gfortran python3-dev
sudo pip3 install numpy

Determine your CUDA architecture version

When compiling OpenCV’s “dnn” module with NVIDIA GPU support, we’ll need to determine our NVIDIA GPU architecture version:

This version number is a requirement when we set the CUDA_ARCH_BIN variable in our cmake command in the next section. The NVIDIA GPU architecture version is dependent on which GPU you are using, so ensure you know your GPU model ahead of time. Failing to correctly set your CUDA_ARCH_BIN variable can result in OpenCV still compiling but failing to use your GPU for inference (making it troublesome to diagnose and debug). One of the easiest ways to determine your NVIDIA GPU architecture version is to simply use the nvidia-smi command:

nvidia-smi
Mon Jan 27 14:11:32 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.104      Driver Version: 410.104      CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla V100-SXM2...  Off  | 00000000:00:04.0 Off |                    0 |
| N/A   35C    P0    38W / 300W |      0MiB / 16130MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

Then:

https://developer.nvidia.com/cuda-gpus

I have a GeForce and TITAN Products with a compute capability of: 6.1

Download OpenCV and compile source code

mkdir ~/src
cd ~/src

wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.2.0.zip
aunpack opencv_contrib.zip
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.2.0.zip
aunpack opencv.zip
cd ./opencv-4.2.0
mkdir build
cd build

I had to install and use a older compiler:

sudo apt install gcc-7 g++-7

You can then run the following cmake command, making sure you set the CUDA_ARCH_BIN variable based on your NVIDIA GPU architecture version:

 cmake -D CMAKE_BUILD_TYPE=RELEASE \
	-D CMAKE_INSTALL_PREFIX=/usr/local \
	-D INSTALL_PYTHON_EXAMPLES=ON \
	-D INSTALL_C_EXAMPLES=OFF \
	-D OPENCV_ENABLE_NONFREE=ON \
	-D WITH_CUDA=ON \
	-D WITH_CUDNN=ON \
	-D OPENCV_DNN_CUDA=ON \
	-D ENABLE_FAST_MATH=1 \
	-D CUDA_FAST_MATH=1 \
	-D CUDA_ARCH_BIN=6.1 \
	-D WITH_CUBLAS=1 \
	-D OPENCV_EXTRA_MODULES_PATH=~/src/opencv_contrib-4.2.0/modules/ \
	-D HAVE_opencv_python3=ON \
        -D CUDNN_INCLUDE_DIR=/usr/include \
        -D CUDNN_LIBRARY=/usr/lib/x86_64-linux-gnu/libcudnn.so.7.6.0 \
        -D CUDNN_VERSION=7.6.3 \
        -D WITH_PROTOBUF=ON \
        -D CUDA_HOST_COMPILER:FILEPATH=/usr/bin/gcc-7 \
	-D BUILD_EXAMPLES=ON ..

Seems there is a bug of sorts? Dont use -j4. Not sure, anyway...

make -j3
sudo make install
sudo ldconfig