1. cuda安装
1.1. 安装cuda-11.2
sudo dpkg -i cuda-repo-ubuntu........._amd64.deb
sudo apt-get -y install cuda
sudo gedit ~/.bashrc
加入.bashrc:
#cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
刷新bashrc
source ~/.bashrc
1.2. 测试是否安装成功
nvidia-smi
查看版本是否对应
nvcc -V
测试是否安装成功:
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
2. cudnn安装
2.1. 下载并安装cudnn
tar -xzvf cudnn-11.5-linux-x64-v8.3.0.98.tgzsudo cp cuda/include/* /usr/local/cuda/includesudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*sudo dpkg -i libcudnn8_8.3.0.98-1+cuda11.5_amd64.debsudo dpkg -i libcudnn8-dev_8.3.0.98-1+cuda11.5_amd64.debsudo dpkg -i libcudnn8-samples_8.3.0.98-1+cuda11.5_amd64.deb
2.2. 测试cudnn是否安装成功
验证:
cd /usr/src/cudnn_samples_v8/mnistCUDNN/
sudo make clean
sudo make
./mnistCUDNN
2.3. 查看cudnn版本
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
3. gRPC安装
3.1. 下载并安装gRPC
查看是否安装cmake,版本大于3.13
cmake --version
安装cmake
sudo apt install -y cmake
安装构建 gRPC 所需的基本依赖工具
sudo apt install -y build-essential autoconf libtool pkg-config
下载grpc(下载可能很慢)
git clone --recurse-submodules -b v1.46.3 --depth 1 --shallow-submodules https://github.com/grpc/grpc
解压
tar -xvzf grpc_1.30.tar.gz
cd grpc
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF ../..
$ make -j
$ make install DESTDIR=安装路径
$ popd
加入环境变量
sudo gedit ~/.bashrc
# grpc
export GRPC_ROOT=/home/user /3rd_pag/grpc/usr/local
export PATH=$PATH:$GRPC_ROOT/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GRPC_ROOT/lib
export LIBRARY_PATH=$LIBRARY_PATH:$GRPC_ROOT/lib
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$GRPC_ROOT/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$GRPC_ROOT/include
source ~/.bashrc
3.2. 测试grpc是否安装成功
cd examples/cpp/helloworld
mkdir -p cmake/build
pushd cmake/build
cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
make -j
./greeter_server
另开终端
./greeter_client
output:
Greeter received: Hello world
4. OpenCV安装
4.1. 直接解压缩对应包
4.2. 安装依赖:
sudo apt-get install qt5-default
sudo apt update
sudo apt upgrade
sudo apt install build-essential cmake pkg-config unzip yasm git checkinstall
sudo apt install libjpeg-dev libpng-dev libtiff-dev
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavresample-dev
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev
sudo apt install libfaac-dev libmp3lame-dev libvorbis-dev
sudo apt install libopencore-amrnb-dev libopencore-amrwb-dev
sudo apt-get install libdc1394-22 libdc1394-22-dev libxine2-dev libv4l-dev v4l-utils
cd /usr/include/linux
sudo ln -s -f ../libv4l1-videodev.h videodev.h
cd ~
sudo apt-get install libgtk-3-dev
sudo apt-get install libtbb-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
4.3 略
4.4 略
以上两个小章节需要对应查看readme文件!
4.5. cmake
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D WITH_TBB=ON -D WITH_CUDA=ON -D BUILD_opencv_cudacodec=OFF -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_GSTREAMER=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_PC_FILE_NAME=opencv.pc -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D CUDA_ARCH_BIN=7.5 -D CUDA_ARCH_PTX=7.5 -D WITH_NVCUVID=ON -D BUILD_TIFF=ON -DBUILD_TIFF=ON ..
4.6. make install
nproc
make -j4 #根据CPU线程数量或nproc结果定义
sudo make install DESTDIR=安装路径
4.7. 加入环境变量
sudo gedit ~/.bashrc
# opencv
export OPENCV_ROOT=/home/user/3rd_pag/opencv-4.4.0/usr/local
export PATH=$PATH:$OPENCV_ROOT/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OPENCV_ROOT/lib
export LIBRARY_PATH=$LIBRARY_PATH:$OPENCV_ROOT/lib
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$OPENCV_ROOT/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$OPENCV_ROOT/include
刷新bashrc
source ~/.bashrc
4.8. 其他依赖库
sudo apt install libeigen3-dev
sudo apt install libboost-dev
5. python运行环境
安装anaconda后,具体参看代码包的readme