win10 +warp-CTC安装 pytorch_binding

版权声明:文章为网上公开资源结合个人情况修改整理。如有侵权,请联系删除。 https://blog.csdn.net/qq_41895190/article/details/82818615

warp-CTC安装

http://www.pianshen.com/article/862428080/

warpctc_pytorch 编译不成功的解决办法


warp-CTC是百度开源的一个可以应用在CPU和GPU上高效并行的CTC代码库,对CTC算法进行了并行处理。

warp-CTC安装:

git clone https://github.com/SeanNaren/warp-ctc.git
cd warp-ctc
mkdir build; cd build
cmake ..
make
cd ../pytorch_binding
python setup.py install

添加环境变量:

gedit ./.bashrc
export WARP_CTC_PATH=/home/xxx/warp-ctc/build


验证pytorch中warp-CTC是否可用GPU例子:

cd /home/xxx/warp-ctc/pytorch_binding/tests
python test_gpu.py
OK输出:

或:

import torch
from torch.autograd import Variable
from warpctc_pytorch import CTCLoss
ctc_loss = CTCLoss()
# expected shape of seqLength x batchSize x alphabet_size
probs = torch.FloatTensor([[[0.1, 0.6, 0.1, 0.1, 0.1], [0.1, 0.1, 0.6, 0.1, 0.1]]]).transpose(0, 1).contiguous()
labels = Variable(torch.IntTensor([1, 2]))
label_sizes = Variable(torch.IntTensor([2]))
probs_sizes = Variable(torch.IntTensor([2]))
probs = Variable(probs, requires_grad=True) # tells autograd to compute gradients for probs
cost = ctc_loss(probs, labels, probs_sizes, label_sizes)
cost.backward()
print('PyTorch bindings for Warp-ctc')

PyTorch bindings for Warp-ctc参考:https://github.com/SeanNaren/warp-ctc
--------------------- 
 
原文:https://blog.csdn.net/dcrmg/article/details/80199722  

========win10 +pytorch 

CMakeLists.txt中添加此行:
set(CUDA_curand_LIBRARY“C:/ Program Files / NVIDIA GPU Computing Toolkit / CUDA / v9.2 / lib / x64 / curand.lib”)

如果发生'Dll Load Failed'错误,请复制生成的warpctc.dll并从torch目录复制caffe2_gpu.dll,caffe2.dll,粘贴到安装目录。

与VS 2017一起构建

git clone https://github.com/amberblade/warp-ctc
cd warp-ctc
mkdir build; 
cd build
cmake -G "Visual Studio 15 2017 Win64" ..

现在去构建目录,打开sln文件并构建解决方案

然后安装绑定:

cd pytorch_binding
python setup.py install

如果您尝试上述并获得“DLL加载失败”错误:

cd ../pytorch_binding
python setup.py install
cd ../build
cp warpctc.dll /path/to/your/warp-ctc/installed
# find your caffe2_gpu.dll and caffe2.dll, and copy to /path/to/your/warp-ctc/installed

Wrap-CTC的简单编译(只涉及cpu部分 linux) https://blog.csdn.net/qq_26819733/article/details/53608308

猜你喜欢

转载自blog.csdn.net/qq_41895190/article/details/82818615