在ubuntu server上配置cuda & opencv

准备文件:

  • cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
  • gpucomputingsdk_4.0.17_linux.run
  • NPP_3.1_Linux64.tar.gz
  • OpenCV-2.3.1a.tar.bz2
安装显卡驱动:
安装cuda:
  • sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
  • ./cudatoolkit_4.0.17_linux_64_ubuntu10.10.run
  • 设置环境变量:

    export CUDA_HOME="/opt/cuda"
    export CUDA_LIB="$CUDA_HOME/lib64:$CUDA_HOME/lib"
    
    export PATH="$CUDA_HOME/bin:$PATH"
    export LD_LIBRARY_PATH="$CUDA_LIB:$LD_LIBRARY_PATH"
  • ./gpucomputingsdk_4.0.17_linux.run
  • 测试:
    cd ~/NVIDIA_GPU_Computing_SDK/C
    # use gcc-4.4 g++-4.4
    make
    # test if work
    ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/deviceQuery
安装opencv
  • tar -xvf NPP_3.1_Linux64.tar.gz
  • tar -xvf OpenCV-2.3.1a.tar.bz2
  • cd OpenCV-2.3.1
  • sudo apt-get install libjpeg62-dev
  • sudo apt-get install libtiff4-dev
  • sudo apt-get install build-essential libavcodec-dev libavformat-dev libjpeg62-dev cmake libswscale-dev libjasper-dev
  • NPP_SDK=$(readlink -f ../NPP_3.1_Linux64)
  • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_NPP_LIBRARY_ROOT_DIR=$NPP_SDK -D WITH_CUDA=ON -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .
  • make
  • sudo make install
  • cd samples
  • sudo apt-get install pkg-config
  • chmod +x build_all.sh
参考:

发表评论