Pytorch使用大核的卷积神经网络: RepLKNet

RepLKNet 项目在这里: https://github.com/DingXiaoH/RepLKNet-pytorch

使用最简单的方法是:

from replknet import create_RepLKNet31B
model = create_RepLKNet31B(num_classes=10)


# 这样没有优化,运行起来非常慢。

要加速,就是安装加速代码:

下载,解压 cutlass.zip

cd /examples/19_large_depthwise_conv2d_torch_extension

安装 

sudo python setup.py install --user

验证是否安装成功:

python depthwise_conv2d_implicit_gemm.py

# 添加环境变量:
pwd             #/home/ubuntu/code/cutlass/examples/19_large_depthwise_conv2d_torch_extension
vi ~/.bashrc
export PYTHONPATH=/home/ubuntu/code/cutlass/examples/19_large_depthwise_conv2d_torch_extension:$PYTHONPATH
export LARGE_KERNEL_CONV_IMPL=/home/ubuntu/code/cutlass/examples/19_large_depthwise_conv2d_torch_extension

对比没加速与加速的耗时,加速后的耗时是没加速的40%,一倍多的加速。

(cutlass.zip 及 网络模型文件请在RepLKNet项目中获取)

猜你喜欢

转载自blog.csdn.net/makao007/article/details/127675862