配置Dese Pose(ソースコードのコンパイルプロセスはサーバに適用されます)


配置Dese Pose(ソースコードのコンパイルプロセスはサーバに適用されます)
  • システム:Ubuntu 14.04
  • グラフィックス:GTX 1060 6 GB
  • #     densepose     cmake>=3.5,      cmake3.12   ,   cmake3.12  gcc-5 g++-5,    sudo     gcc g++   。
    #        Ubuntu 14.04      ,     Linux    gcc-5 g++-5        
    #   gcc g++
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test  
    sudo apt-get update
    sudo apt-get install gcc-5 g++-5  
    cd /usr/bin  
    sudo rm -rf gcc g++
    sudo ln -s gcc-5 gcc
    sudo ln -s g++-5 g++ 
    #        /home/michael/local,      (  bin,lib,include,share)               ,  cuda
    # PS:    NVIDIA driver cuda_8.0.61(       (Ubuntu Desktop)                    ,         )
    vim /etc/modprobe.d/blacklist.conf
    #        blacklist nouveau 
    #    nouveau      ,        sudo  
    sudo update-initramfs -u
    #     , cuda_8.0.61_375.26_linux.run            
    #   Ctrl + Alt + F1        ,        X Server,  sudo  
    sudo /etc/init.d/lightdm stop
    #       
    chmod a+x cuda_8.0.61_375.26_linux.run
    ./cuda_8.0.61_375.26_linux.run #      ,    
    #                 
    
    Do you accept the previously read EULA?
    accept/decline/quit: accept
    
    Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
    (y)es/(n)o/(q)uit: yes
    
    Install the CUDA 8.0 Toolkit?
    (y)es/(n)o/(q)uit: yes
    
    Enter Toolkit Location
     [ default is /usr/local/cuda-8.0 ]: /home/michael/local/cuda_8.0.61
    
    #        OpenGL  no    ,      ,      ,        X Server    
    sudo /etc/init.d/lightdm restart
    #     nvidia-smi                   ,          OK  ,      cuda_8.0.61        
    
    # PS:                  640x480         ,     
    #              ,    sudo
    sudo gedit /etc/X11/xorg.conf
    #           ,       ,  
    Section "ServerLayout"
        Identifier     "Layout0"
        Screen      0  "Screen0"
        InputDevice    "Keyboard0" "CoreKeyboard"
        InputDevice    "Mouse0" "CorePointer"
    EndSection
    
    Section "Files"
    EndSection
    
    Section "InputDevice"
        # generated from default
        Identifier     "Mouse0"
        Driver         "mouse"
        Option         "Protocol" "auto"
        Option         "Device" "/dev/psaux"
        Option         "Emulate3Buttons" "no"
        Option         "ZAxisMapping" "4 5"
    EndSection
    
    Section "InputDevice"
        # generated from default
        Identifier     "Keyboard0"
        Driver         "kbd"
    EndSection
    
    Section "Monitor"
        Identifier     "Monitor0"
        VendorName     "Unknown"
        ModelName      "Unknown"
        HorizSync       31.5 - 61.0 #      
        VertRefresh     50.0 - 75.0 #      
        Option         "DPMS"
    EndSection
    
    Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
    EndSection
    
    Section "Screen"
        Identifier     "Screen0"
        Device         "Device0"
        Monitor        "Monitor0"
        DefaultDepth    24
        SubSection     "Display"
            Depth       24
        Modes "1920×1080"  #      
        EndSubSection
    EndSection
    #     OK,              
    #   cuda_8.0.61
    chmod a+x cuda_8.0.61_375.26_linux.run
    ./cuda_8.0.61_375.26_linux.run
    #   cuda_8.0.61       /home/michael/local/cuda_8.0.61
    #        cuda8.0.61        
    vim ~/.bashrc
    #      
    export PATH=/home/michael/local/cuda_8.0.61/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/home/michael/local/cuda_8.0.61/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    export C_INCLUDE_PATH=/home/michael/local/cuda_8.0.61/include${C_INCLUDE_PATH:+:${C_INCLUDE_PATH}}
    export CPLUS_INCLUDE_PATH=/home/michael/local/cuda_8.0.61/include${CPLUS_INCLUDE_PATH:+:${CPLUS_INCLUDE_PATH}}
    #         
    source ~/.bashrc
    #    nvcc -V     cuda          
    #   cudnn6.0
    tar -zxvf cudnn-8.0-linux-x64-v6.0.tgz #            cuda
    cd cuda/include
    cp cudnn.h /home/michael/local/cuda_8.0.61/include
    cd ../lib64
    cp -a lib* /home/michael/local/cuda_8.0.61/lib64
    #    cudnn      cuda        ,      cuda  ,               
    #   opencv3.3
    unzip opencv-3.3.0.zip
    cd opencv-3.3.0 
    mkdir build
    cd build
    #               
    cmake \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/home/michael/local \
    -D WITH_TBB=ON \
    -D BUILD_NEW_PYTHON_SUPPORT=ON \
    -D WITH_V4L=ON \
    -D INSTALL_C_EXAMPLES=ON \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D WITH_QT=ON \
    -D WITH_OPENGL=ON ..
    #       
    make -j4
    make install
    #                 opencv,      local  ,                                   
    vim ~/.bashrc #      
    export PATH=/home/michael/local/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/home/michael/local/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    export C_INCLUDE_PATH=/home/michael/local/include${C_INCLUDE_PATH:+:${C_INCLUDE_PATH}}
    export CPLUS_INCLUDE_PATH=/home/michael/local/include${CPLUS_INCLUDE_PATH:+:${CPLUS_INCLUDE_PATH}}
    export PKG_CONFIG_PATH=/home/michael/local/lib/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
    #         
    source ~/.bashrc
    #    opencv_version     opencv          
    #   cmake3.12
    tar -zxvf cmake-3.12.0.tar.gz
    cd cmake-3.12.0
    ./bootstrap --prefix=/home/michael/local/ 
    make -j4 
    make install
    #   Anaconda2,  Anaconda python         ,    python    ,       Anaconda  
    sh Anaconda2-5.0.1-Linux-x86_64.sh
    #        /home/michael/local/anaconda2,                 
    #        yes Anaconda2   ~/.bashrc    ,        Python       Anaconda      Python
    #         pip ,     pip        pip    ,        
    #            pip ,Anaconda    python     ,    :
    cd ~/ && mkdir .pip && cd .pip && vim pip.conf
    #     :
    [global]  
    index-url=https://pypi.tuna.tsinghua.edu.cn/simple
    [install]  
    trusted-host=pypi.tuna.tsinghua.edu.cn 
    disable-pip-version-check = true  
    timeout = 6000
    #       ,                   Densepose Caffe2 python   ,      
    pip install --ignore-installed -U pip numpy pyyaml matplotlib setuptools Cython mock scipy typing future protobuf opencv-python memory-profiler
    #          sudo  ,      sudo apt-get install XXX                    ,            
    #          ,            
    
    # zlib
    #     Anaconda     Ubuntu    zlib,  Ubuntu     zlib   zlib_1.2.11.dfsg.orig.tar.xz     。
    #   zlib_1.2.11.dfsg.orig.tar.xz,   zlib-1.2.11,   
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # cocoapi
    git clone --recursive https://github.com/cocodataset/cocoapi.git
    cd cocoapi/PythonAPI && make && make install
    #   python  import pycocotools.coco     cocoapi    
    
    # openblas
    tar -zxvf OpenBLAS-0.2.20.tar.gz
    cd OpenBLAS-0.2.20/
    make -j4 && make PREFIX=/home/michael/local install
    
    # snappy
    tar -zxvf snappy-1.1.4.tar.gz
    cd snappy-1.1.4/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # gtest
    tar -zxvf gtest-1.5.0.tar.gz
    cd gtest-1.5.0/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # glog
    tar -zxvf glog-0.3.3.tar.gz
    cd glog-0.3.3/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # leveldb
    unzip leveldb-1.20.zip
    cd leveldb-1.20/
    make -j4
    cd include/
    cp -r leveldb/ /home/michael/local/include
    cd ..
    cd out-shared/
    cp -a lib* /home/michael/local/lib/
    
    # hdf5
    tar -zxvf hdf5-1.8.17.tar.gz
    cd hdf5-1.8.17/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # lmdb
    tar -zxvf lmdb-LMDB_0.9.22.tar.gz
    cd lmdb-LMDB_0.9.22/libraries/liblmdb
    vim Makefile
    #     prefix  = /home/michael/local
    make -j4
    make install 
    
    # gflag
    unzip gflags-master.zip
    cd gflags-master/
    mkdir build
    cd build
    cmake -D CMAKE_INSTALL_PREFIX=/home/michael/local ..
    make -j4
    make install
    
    # protobuf
    tar -zxvf protobuf-cpp-3.5.0.tar.gz
    cd protobuf-3.5.0/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # openmpi
    tar -zxvf openmpi-3.1.1.tar.gz
    cd openmpi-3.1.1/
    ./configure --prefix=/home/michael/local
    make -j4
    make install
    
    # caffe2
    git clone --recursive https://github.com/pytorch/pytorch.git 
    cd pytorch 
    git submodule update --init 
    mkdir build 
    cd build
    #   /home/michael/local/caffe2  ,    caffe2           caffe     ,     caffe2            
    cmake -D CMAKE_INSTALL_PREFIX=/home/michael/local/caffe2 ..
    make install -j4
    #   PYTHON    
    vim ~/.bashrc
    export PYTHONPATH=/home/michael/pytorch/build${PYTHONPATH:+:${PYTHONPATH}}
    #   caffe2       GPU
    michael@hp:~/pytorch/build$ python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
    Success #  Success
    # densepose
    git clone --recursive https://github.com/facebookresearch/densepose
    cd densepose
    make -j4
    python detectron/tests/test_spatial_narrow_as_op.py
    #  OK
    make ops -j4
    #  ,   caffe2,  ,          cuda9 cudnn7, densepose   cuda8 cudnn6  ,   make ops      make。
    cd build #    make      build
    #        
    cmake \
    -D CUDA_TOOLKIT_ROOT_DIR=/home/michael/local/cuda_8.0.61 \
    -D CUDNN_INCLUDE_DIR=/home/michael/local/cuda_8.0.61/include \
    -D CUDNN_LIBRARY=/home/michael/local/cuda_8.0.61/lib64/libcudnn.so \
    -D CMAKE_PREFIX_PATH=/home/michael/local/caffe2 ..
    make -j4
    cd ..
    python detectron/tests/test_zero_even_op.py
    #  OK,  densepose         ,                   demo
    
    #      
    DensePose_ResNet101_FPN_s1x-e2e.pkl
    DensePoseData/eval_data   # DensePoseData/get_eval_data.sh       
    DensePoseData/UV_data    # DensePoseData/get_densepose_uv.sh       
    
    #    densepose                 demo
    python2 tools/infer_simple.py \
        --cfg configs/DensePose_ResNet101_FPN_s1x-e2e.yaml \
        --output-dir DensePoseData/infer_out/ \
        --image-ext jpg \
        --wts DensePose_ResNet101_FPN_s1x-e2e.pkl \
        DensePoseData/demo_data/demo_im.jpg
    #     X Server                ,     imshow       
    #      DensePoseData/infer_out     demo_im_INDS.png  demo_im_IUV.png  demo_im.jpg.pdf