重装了几次系统后,终于能含泪写下自己的安装过程,为以后重装做个记录T T
Ubuntu18.04安装英伟达显卡驱动
安装nvidia驱动418.56
安装后续步骤或环境必需的依赖包,依次输入以下命令:
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install git cmake build-essential
sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libgl1-mesa-dev libglu1-mesa libglu1-mesa-dev libxi-dev
在CUDA所在的文件夹中打开终端,输入以下命令:
sudo sh cuda_10.0.130_410.48_linux.run
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: n ##一定要选N
Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-10.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /home/srq ]:
Installing the CUDA Toolkit in /usr/local/cuda-10.0 ...
Installing the CUDA Samples in /home/srq ...
Copying samples to /home/srq/NVIDIA_CUDA-10.0_Samples now...
Finished copying samples.
sudo gedit ~/.bashrc
在文件末尾添加:
export PATH=/usr/local/cuda-10.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
nvcc --version
cat /usr/local/cuda/version.txt
cd /usr/local/cuda-10.0/samples
sudo make all -j16
cd ./bin/x86_64/linux/release
./deviceQuery
在cudnn所在文件夹中,打开终端,运行以下命令解压:
tar -xzvf cudnn-10.0-linux-x64-v7.5.1.10.tgz
cd cuda
cd ./include
sudo cp cudnn.h /usr/local/cuda/include/
cd ../lib64
sudo cp lib* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.7
sudo ln -s libcudnn.so.7.5.1 libcudnn.so.7
sudo ln -s libcudnn.so.7 libcudnn.so
sudo ldconfig -v
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
解压压缩包,进入解压好的opencv-3.4.0中
mkdir build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make all -j16
sudo make install
sudo gedit /etc/ld.so.conf.d/opencv.conf
打开的是一个空白的文件,在文件中添加
/usr/local/lib
执行如下命令使得刚才的配置路径生效:
sudo ldconfig
配置bash:
sudo gedit /etc/bash.bashrc
在文件末尾添加:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
执行如下命令使得配置生效:
source /etc/bash.bashrc
更新:
sudo updatedb
cd opencv-3.4.0/samples/cpp/example_cmake
cmake .
make
./opencv_example