pytorch0.4 ctc_のインストールloss

27842 ワード

文書ディレクトリ

  • インストールフロー
  • 注意:
  • FAQ
  • 前言:pytorch 0.4.1のインストールは私の別のブログpytorch 0を参考にすることができます.4.1 CTC loss pytorch 1をインストールする.0後フレームワークにctc損失関数が付属

    インストールプロセス

  • プロジェクトをクローンし、ルートディレクトリの下にbuildフォルダ
  • を新規作成
    git clone https://github.com/SeanNaren/warp-ctc.git
    cd warp-ctc
    mkdir build; cd build
    cmake ..
    make
    
  • 対元ファイル:pytorch_binding/src/binding.cppは2箇所修正:
  • 1 at 92 lines
    int probs_size = THCudaTensor_size(state, probs, 2);
    2 at l05 lines
    void* gpu_workspace;
    THCudaMalloc(state, &gpu_workspace, gpu_size_bytes);
    
  • コンパイルインストール
  • cd pytorch_binding
    python setup.py install
    
  • テスト
  • cd pytorch_binding/tests/
    python test_cpu.py
    python test_gpu.py
    
    >>>
    =========================================================================================== test session starts ============================================================================================
    platform linux -- Python 3.6.7, pytest-4.0.0, py-1.8.0, pluggy-0.9.0
    rootdir: /home/chenjun/warp-ctc/pytorch_binding, inifile: setup.cfg
    collected 4 items                                                                                                                                                                                          
    
    test_cpu.py ....                                                                                                                                                                                     [100%]
    
    ========================================================================================= 4 passed in 0.10 seconds =========================================================================================
    (torch04) chenjun@chenjun-MS-7A71:~/warp-ctc/pytorch_binding/tests$ python test_gpu.py 
    =========================================================================================== test session starts ============================================================================================
    platform linux -- Python 3.6.7, pytest-4.0.0, py-1.8.0, pluggy-0.9.0
    rootdir: /home/chenjun/warp-ctc/pytorch_binding, inifile: setup.cfg
    collected 4 items                                                                                                                                                                                          
    
    test_gpu.py ....                                                                                                                                                                                     [100%]
    
    ========================================================================================= 4 passed in 2.02 seconds =========================================================================================
    (torch04) chenjun@chenjun-MS-7A71:~/warp-ctc/pytorch_binding/tests$ git commit
    

    注意:

  • pytorch0.4.1以上の修正は不要、0.4.0以上の修正が必要
  • pytorch0.4.0修正後、gpuをテストするとき、ずっと動かない.

  • よくある質問

  • gccコンパイル時にsrc/bindingが現れる.cpp:6:29: fatal error: torch/extension.h:そのファイルやディレクトリはありません.詳細なエラーは下図を参照してください.これはプロジェクトの異なるバージョンによる問題です.
  • gcc -pthread -B /home/yangna/yangna/tool/anaconda2/envs/torch40/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/yangna/yangna/tool/warp-ctc/include -I/home/yangna/yangna/tool/anaconda2/envs/torch40/lib/python3.6/site-packages/torch/lib/include -I/home/yangna/yangna/tool/anaconda2/envs/torch40/lib/python3.6/site-packages/torch/lib/include/TH -I/home/yangna/yangna/tool/anaconda2/envs/torch40/lib/python3.6/site-packages/torch/lib/include/THC -I/usr/local/cuda/include -I/home/yangna/yangna/tool/anaconda2/envs/torch40/include/python3.6m -c src/binding.cpp -o build/temp.linux-x86_64-3.6/src/binding.o -std=c++11 -fPIC -DWARPCTC_ENABLE_GPU -DTORCH_EXTENSION_NAME=warpctc_pytorch._warp_ctc
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    src/binding.cpp:6:29: fatal error: torch/extension.h:          
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    

    解決:git checkout ac 045 b 6、ブランチの切り替え