• Docker: 小白之路九(从0搭建自己的Docker环境centos7)


    Docker环境配置centos7版本

    一. 配置对应的docker环境和nvidia-docker(注意加速镜像设置)

    二. 环境配置

    1. 拉取对应的镜像

    docker pull nvidia/cuda:10.2-cudnn7-devel-centos7
    
    • 1

    2. 创建新版本的容器并搭建对应的环境

    docker run -it --name felaim_sever_centos7 nvidia/cuda:10.2-cudnn7-devel-centos7 /bin/bash
    
    • 1
    1. 更新对应的源和软件
    yum  update
    yum upgrade
    
    • 1
    • 2
    2. 安装wget
    yum -y install wget
    
    • 1
    3. 确定g++和gcc版本

    最好是用5.4.0版本的,4.8.5对有些软件安装会有问题例如OpenCV4.2的GPU版本

    gcc --version
    
    • 1
    a. 安装解压缩包bzip2
    yum install bzip2
    
    • 1
    b. 下载对应源码并解压(网容易不好,要多试几次才行)
    cd /usr/local/src
    wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2
    tar -jxvf gcc-5.4.0.tar.bz2
    
    • 1
    • 2
    • 3
    c.下载相关依赖组件(网不好,用热点会好一些)
    cd gcc-5.4.0
    ./contrib/download_prerequisites
    
    • 1
    • 2
    d. 建立一个文件夹存放编译的文件
    mkdir gcc-build-5.4.0
    cd gcc-build-5.4.0
    /usr/local/src/gcc-5.4.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib  
    
    • 1
    • 2
    • 3
    e. 编译并安装

    出现问题,没有安装make

    make -j4 //开四个线程进行编译
    bash: make: command not found
    
    • 1
    • 2

    解决方法

    yum -y install gcc automake autoconf libtool make
    
    • 1

    安装

    make install
    
    • 1

    更新软链接

    cd /usr/bin/
    mv gcc gcc_back
    mv g++ g++_back
    ln -s /usr/local/bin/gcc gcc
    ln -s /usr/local/bin/g++ g++
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    f. 推送对应的镜像到仓库
    将容器变成镜像
    docker commit -a "runoob.com" -m "my apache" a404c6c174a2  mymysql:v1
    
    • 1

    OPTIONS说明:

    • -a :提交的镜像作者;

    • -c :使用Dockerfile指令来创建镜像;

    • -m :提交时的说明文字;

    • -p :在commit时,将容器暂停。

    将镜像推入仓库

    重新定义tag的名字

    #docker  tag  镜像id       要推入仓库的用户名/要推入的仓库名:新定义的tag 
    docker tag e12a9ec48ab7    felaim/felaim_sever:myproject
    
    • 1
    • 2
    #docker push  要推入仓库的用户名/要推入的仓库名:镜像标签
    docker push  felaim/felaim_sever:myproject
    
    • 1
    • 2

    安装gdb

    wget ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz
    tar -xzvf gdb-7.8.tar.gz
    cd gdb-7.8
    ./configure
    make 
    
    • 1
    • 2
    • 3
    • 4
    • 5

    出现错误

    configure: WARNING: no enhanced curses library found; disabling TUI
    checking for library containing tgetent... no
    configure: error: no termcap library found
    make[1]: *** [configure-gdb] Error 1
    make[1]: Leaving directory `/usr/local/src/gdb-7.8'
    make: *** [all] Error 2
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    yum -y install ncurses-devel
    
    • 1

    重新configu后,make,make install

    安装cmake

    For example, if you simply want to build and install CMake from source,
    you can build directly in the source tree::
    
      $ ./bootstrap && make && sudo make install
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    报错

    gmake: `cmake' is up to date.
    /usr/local/src/cmake-3.15.7/Bootstrap.cmk/cmake: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/src/cmake-3.15.7/Bootstrap.cmk/cmake)
    /usr/local/src/cmake-3.15.7/Bootstrap.cmk/cmake: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/src/cmake-3.15.7/Bootstrap.cmk/cmake)
    
    • 1
    • 2
    • 3

    解决方法

    cp /usr/local/lib64/libstdc++.so.6.0.21 /usr/lib64/
    cd /usr/lib64/
    rm -f libstdc++.so.6
    ln -s libstdc++.so.6.0.21 libstdc++.so.6   
    
    • 1
    • 2
    • 3
    • 4

    问题解决后运行gmake

    gmake
    make install
    cmake -version
    
    • 1
    • 2
    • 3

    安装locate

    bash: locate: command not found
    yum install mlocate
    
    • 1
    • 2

    出现问题

    locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
    updatedb
    
    • 1
    • 2

    安装protobuf (2020.4.20)

    安装tf1.14对应的protobuf需要3.7.1版本的,所以先提前安装好,这样OpenCV链接之间链接3.7.1版本的即可
    下载对应版本的protobuf(git clone怎么选择tag和version)

    使用–branch指定分支,也得多试几次,开手机热点比较快

    git clone --branch v3.7.1 https://github.com/protocolbuffers/protobuf.git
    
    cd protobuf
    
    //配置脚本
    ./autogen.sh
    
    //编译与安装
    ./configure
    
    make
    make check
    sudo make install
    sudo ldconfig # refresh shared library cache.
    protoc --version
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    出现warning(暂未解决)

    === configuring in third_party/googletest (/home/software/protobuf/third_party/googletest)
    configure: WARNING: no configuration information is in third_party/googletest
    
    • 1
    • 2

    安装eigen

    下载对应安装包

    mkdir build
    cd build
    cmake ..
    make install
    
    • 1
    • 2
    • 3
    • 4

    安装bazel

    yum install unzip
    ./bazel-0.24.1-installer-linux-x86_64.sh --user
    export PATH="$PATH:$HOME/bin"
    
    • 1
    • 2
    • 3

    TensorRT

    下载对应版本, TensorRT-6.0.1.8.CentOS-7.6.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz

    tar -zxvf TensorRT-6.0.1.8.CentOS-7.6.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
    
    • 1
    • 2

    tensorflow1.14

    ./configure中path的设置
    /usr/local/cuda,/usr/local/cuda/bin,/usr/local/cuda/lib64,/usr/local/cuda/include,/home/software/TensorRT-6.0.1.8,/usr/lib/x86_64-linux-gnu,/usr/include,/usr/lib64
    
    
    • 1
    • 2
    • 3
    patch command is not found, please install it and referenced by '//third_party/eigen3:eigen3'
    yum -y install  patch
    
    • 1
    • 2
    ERROR: /root/.cache/bazel/_bazel_root/79617ab99e45fd3cf89b3b67f497350d/external/nccl_archive/BUILD.bazel:67:1: fatbinary external/nccl_archive/device_dlink_hdrs.fatbin failed (Exit 1)
    fatbinary fatal   : Unknown option '-bin2c-path'
    Target //tensorflow:libtensorflow_cc.so failed to build
    Use --verbose_failures to see the command lines of failed build steps.
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    3. 安装OpenCV 4.2版本

    安装OpenCV4.2版本,安装对应依赖项

    sudo yum -y install epel-release
    sudo yum -y install qt5-qtbase-devel gtk2-devel libpng-devel jasper-devel openexr-devel libwebp-devel libjpeg-turbo-devel freeglut-devel mesa-libGL mesa-libGL-devel libtiff-devel libdc1394-devel tbb-devel eigen3-devel boost boost-thread boost-devel libv4l-devel gstreamer-plugins-base-devel
    
    • 1
    • 2
    mkdir /home/software/
    git clone https://github.com/opencv/opencv.git
    git clone https://github.com/opencv/opencv_contrib.git
    cp -r ./opencv_contrib ./opencv/
    cd opencv
    mkdir build
    cd build
    cmake   -D CMAKE_BUILD_TYPE=RELEASE   -D CMAKE_INSTALL_PREFIX=/usr/local   -D WITH_TBB=ON   -D WITH_V4L=ON   -D WITH_QT=ON   -D WITH_OPENGL=ON   -D WITH_CUDA=ON   -D ENABLE_FAST_MATH=1   -D CUDA_FAST_MATH=1   -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES"   -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ ..
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    参考地址

    gcc, g++升级:

    • https://blog.csdn.net/u011181989/article/details/91334478
    • https://www.vpser.net/manage/centos-6-upgrade-gcc.html
  • 相关阅读:
    C编译器01-扫描器
    Python绘制三维立体图详解
    流批一体随想
    驱动 点灯
    【Linux】UDP的服务端 + 客户端
    jmeter,实现不写文本文件 只要写脚本,自动的给注册
    Linux如何安装Maven?
    【无标题】数字孪生技术即神器而又象征着未来的点滴
    Java开源工作流引擎有什么突出特点?
    PTE SST和RL模板
  • 原文地址:https://blog.csdn.net/Felaim/article/details/105635600