Maskrcnn-benchmark在windows系统的安装

安装pytorch 1.0

之前编译安装pytorch 1.0失败,后面偶然发现可用conda安装了,所以重新用conda来安装,pytorch安装方法:

在这个页面选择好本地环境后会显示执行命令:

conda install pytorch torchvision -c pytorch

安装过程发现拉包有点慢,加了清华的源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --set show_channel_urls yes

但是pytorch还是从国外的源拉的,不仅下载慢,而且很容易断,即使执行了以下语句也不行

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/


Maskrcnn-benchmark在windows系统的安装_第1张图片

手动下载https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/pytorch-1.0.0-py3.6_cuda100_cudnn7_1.tar.bz2后放到

C:\ProgramData\Anaconda3\pkgs\目录下,在执行conda install pytorch torchvision -c pytorch终于安装成功


编译maskrcnn-benchmark

git clone到本地后执行python setup.py build develop 编译过程遇到很多问题,一一解决过程如下:

1 no instance of function template "THCCeilDiv" matches the argument list

错误提示如下:

C:/Users/Administrator/Documents/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of function template "THCCeilDiv" matches the argument list

argument types are: (long long, long)

C:/Users/Administrator/Documents/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of overloaded function "std::min" matches the argument list

argument types are: (, long)

C:/Users/Administrator/Documents/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/ROIAlign_cuda.cu(320): error: no instance of function template "THCCeilDiv" matches the argument list

argument types are: (int64_t, long)

C:/Users/Administrator/Documents/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/ROIAlign_cuda.cu(320): error: no instance of overloaded function "std::min" matches the argument list

argument types are: (, long)

4 errors detected in the compilation of "C:/Users/pazzu/AppData/Local/Temp/tmpxft_00003e80_00000000-10_ROIAlign_cuda.cpp1.ii".

error: command 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA\v10.0\bin\nvcc.exe' failed with exit status 1

参考网上的讨论,maskrcnn-benchmark编译问题,解决方法:

修改maskrcnn_benchmark/maskrcnn_benchmark/csrc/cuda/ROIAlign_cuda.cu第275行:

//原代码: dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));

dim3 grid(std::min(((int)output_size + 512 -1) / 512, 4096));

320行:

//原代码: dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));

  dim3 grid(std::min(((int)(grad.numel()) + 512 -1) / 512, 4096));

修改maskrcnn_benchmark/maskrcnn_benchmark/csrc/cuda/ROIPool_cuda.cu第129行:

// dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));

  dim3 grid(std::min(((int)output_size + 512 -1) / 512, 4096));

177行:

//dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));

  dim3 grid(std::min(((int)(grad.numel()) + 512 -1) / 512, 4096));

2 LINK : fatal error LNK1104: 无法打开文件“kernel32.lib”

找到kernel32.lib所在目录为C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64,添加到环境变量lib中。

3 LINK : fatal error LNK1158: 无法运行“rc.exe”

找到rc.exe所在目录为C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64,添加到环境变量Path中。

demo运行成功:


你可能感兴趣的:(Maskrcnn-benchmark在windows系统的安装)