- python版本是3.6,cuda版本 10.1 update2(之前cuda版本是10.2一直不对,后来查找是10.1 update2,具体有没有作用)
- 报错没有安装ninja
通过python安装ninja
pip install ninja
- 找不到cl.exe
\utils\cpp_extension.py:305: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。warnings.warn(f’Error checking compiler version for {compiler}: {error}’)
找到该行代码,windows下使用的c++是'MINIMUM_MSVC_VERSION'
try:
if sys.platform.startswith('linux'):
minimum_required_version = MINIMUM_GCC_VERSION
versionstr = subprocess.check_output([compiler, '-dumpfullversion', '-dumpversion'])
version = versionstr.decode().strip().split('.')
else:
minimum_required_version = MINIMUM_MSVC_VERSION
compiler_info = subprocess.check_output(compiler, stderr=subprocess.STDOUT)
match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode().strip())
version = (0, 0, 0) if match is None else match.groups()
except Exception:
_, error, _ = sys.exc_info()
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
return False
在文档中找到版本要求,对应该版本的MSVC
MINIMUM_MSVC_VERSION = (19, 0, 24215)
我安装的VS2017,下载 VS2017 installer VS2017下载地址和安装教程(图解) (biancheng.net)http://c.biancheng.net/view/456.html
需要将cl.exe路径添加到环境变量中
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86
具体什么报错忘了,python环境中执行了着个语句
(torch) D:\maskrcnn-benchmark>call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.6
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
还有一个报错 utils\cpp_extension.py:189: UserWarning: Error checking compiler version for cl: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte
utf-8格式不正确,找到文件对应位置,修改为gbk格式,compiler_info.decode('gbk')
报错It seems that the VC environment is activated but DISTUTILS_USE_SDK is not set
在vs2017命令行中执行
set DISTUTILS_USE_SDK=1
如果还报错,删除build文件夹、_ext.cp36-win_amd64.pyd文件,重新生成,
修改pyd文件为_ext.pyd,import _ext 之前添加_ext路径,因为python调用pyd路径有时会找不到
sys.path.append(r'D:\..\..\models\dla\DCNv2')
import _ext as _backend
直接执行文件不报错,但是通过别的文件进行引用还是有问题,待解决
参考连接: