pointnet2_ops编译报错(Windwows上部署)
[Windows]pip install pointnet2_ops报错解决
报错信息👀
(m2t2) PS F:\code_project\Gitub_projects\M2T2-master> pip install pointnet2_ops/ -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Processing f:\code_project\gitub_projects\m2t2-master\pointnet2_ops
Preparing metadata (setup.py) ... done
Requirement already satisfied: torch>=1.4 in e:\anaconda\envs\m2t2\lib\site-packages (from pointnet2_ops==3.0.0) (2.0.1)
Requirement already satisfied: filelock in e:\anaconda\envs\m2t2\lib\site-packages (from torch>=1.4->pointnet2_ops==3.0.0) (3.13.1)
Requirement already satisfied: typing-extensions in e:\anaconda\envs\m2t2\lib\site-packages (from torch>=1.4->pointnet2_ops==3.0.0) (4.10.0)
Requirement already satisfied: sympy in e:\anaconda\envs\m2t2\lib\site-packages (from torch>=1.4->pointnet2_ops==3.0.0) (1.12)
Requirement already satisfied: networkx in e:\anaconda\envs\m2t2\lib\site-packages (from torch>=1.4->pointnet2_ops==3.0.0) (3.2.1)
Requirement already satisfied: jinja2 in e:\anaconda\envs\m2t2\lib\site-packages (from torch>=1.4->pointnet2_ops==3.0.0) (3.1.3)
Requirement already satisfied: MarkupSafe>=2.0 in e:\anaconda\envs\m2t2\lib\site-packages (from jinja2->torch>=1.4->pointnet2_ops==3.0.0) (2.1.5)
Requirement already satisfied: mpmath>=0.19 in e:\anaconda\envs\m2t2\lib\site-packages (from sympy->torch>=1.4->pointnet2_ops==3.0.0) (1.3.0)
Building wheels for collected packages: pointnet2_ops
Building wheel for pointnet2_ops (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [40 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\pointnet2_ops
copying pointnet2_ops\pointnet2_modules.py -> build\lib.win-amd64-cpython-310\pointnet2_ops
copying pointnet2_ops\pointnet2_utils.py -> build\lib.win-amd64-cpython-310\pointnet2_ops
copying pointnet2_ops\_version.py -> build\lib.win-amd64-cpython-310\pointnet2_ops
copying pointnet2_ops\__init__.py -> build\lib.win-amd64-cpython-310\pointnet2_ops
running egg_info
writing pointnet2_ops.egg-info\PKG-INFO
writing dependency_links to pointnet2_ops.egg-info\dependency_links.txt
writing requirements to pointnet2_ops.egg-info\requires.txt
writing top-level names to pointnet2_ops.egg-info\top_level.txt
reading manifest file 'pointnet2_ops.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pointnet2_ops.egg-info\SOURCES.txt'
creating build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src
creating build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\ball_query.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\cuda_utils.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\group_points.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\interpolate.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\sampling.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
copying pointnet2_ops\_ext-src\include\utils.h -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\include
creating build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\ball_query.cpp -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\ball_query_gpu.cu -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\bindings.cpp -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\group_points.cpp -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\group_points_gpu.cu -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\interpolate.cpp -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\interpolate_gpu.cu -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\sampling.cpp -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
copying pointnet2_ops\_ext-src\src\sampling_gpu.cu -> build\lib.win-amd64-cpython-310\pointnet2_ops\_ext-src\src
running build_ext
E:\Anaconda\envs\m2t2\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
error: [WinError 2] 系统找不到指定的文件。
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pointnet2_ops
Running setup.py clean for pointnet2_ops
Failed to build pointnet2_ops
ERROR: Could not build wheels for pointnet2_ops, which is required to install pyproject.toml-based projects
(m2t2) PS F:\code_project\Gitub_projects\M2T2-master>
关键报错如下,就是说定位不到符合版本的cl文件:
解谜开始😥
先喂给GPT问下:
得到关键信息,我们需要对应版本的VS Build Tools
.
此外查找相关博客,参考链接
了解到_MSC_VER
是MSVC编译器的内置宏,定义了编译器的版本。
定位到报错信息中的源文件:
可以看出cl.exe
的版本要求:
MINIMUM_MSVC_VERSION = (19, 0, 24215)
在本机电脑中找到了VS2017的MSVC版本:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC
如何对应版本号?🤨
Microsoft Visual C++ - Wikipedia
我尝试根据表中所列的对照关系,定位到了_MSC_VER
为1924的一栏,可以看到应该是VS2019
的版本,且版本号为16.4.0
。
接下来我们去到VS官网,如下图所示,下载链接对应版本号的BuildTools
.
验证🤮
安装完成:
找到默认安装路径:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
打开目录又傻眼了,翻了半天没找到MSVC文件夹,好像不太一样欸:
应该是没装全,去包管理点击修改:
勾上C++生成工具,然后右侧选择前两个,开始安装。
安装完成,呼~,似乎看到了希望:
尝试点开了其中一个路径:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64
配置环境变量(便于找到cl.exe
)⭐
把这个路径加到系统环境变量的PATH
中,尝试一手再次执行:
fa fa fa 好消息是没有cl报错了,注意到Unicode,应该是编码问题,继续定位报错行,如下出现的解码格式:
将oem
修改为utf-8
一试:
依然报错,少了具体报错行🫵🤮
打印输出match
对象(匹配到的version号):
总结梳理⭐⭐⭐
windows编码问题(autorun)
终端由于在注册表设置了autorun(历史遗留问题,应该是大一写C遇到终端乱码学的解决方式🫥)
,每次启动都会设置编码为utf-8.这样会导致visual studio终端启动报错(vcvarsall.bat)。
如下图所示,找到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor
,将Autorun删除即可。
调用vs检查编码问题
在终端输入如下命令:
cmd.exe /c "E:\VS2019\VC\Auxiliary\Build\vcvars64.bat"
至此,无需在cpp_extension.py中修改解码方式。
Visual Studio版本问题
如果VS和CUDA版本不适配,也会遇到问题,我起初电脑上装的有VS2022,VS2019,2022和我安装的CUDA11.1不适配,这里报错图不再贴出。
经过卸载重装,下了VS2019和VS2017,但是依然报错,随后参考了一篇博客内容,修改MSVC的版本控制。
系统CUDA与conda安装的CUDA
注意区分……
ninja包
这个错误的出现主要是因为pytorch版本大于1.5,可行的解决方法有三个:
-
将pytorch版本降到1.5以下;(本末倒置)
-
将报错的源码
torch/utils/cpp_extension.py
中的[‘ninja’,‘-v’]
修改为[‘ninja’,‘—version’]
(不推荐,试过后产生了新的报错……) -
将
pointnet2/setup.py
中cmdclass修改,pytorch默认使用ninjia作为backend,这里把它禁用掉。
编译成功🫵😁
究极折磨,我为什么要在windows上装🥶🥶🥶