pointnet2的代码来自:
https://github.com/halfsummer11/CAPTRA#dataset-folder-structure
https://github.com/sshaoshuai/Pointnet2.PyTorch
https://github.com/yanx27/Pointnet_Pointnet2_pytorch
在pointnet_lib目录下执行 python setup.py install 后
安装pointnet_lib报错:
D:\Anaconda\envs\pcl\lib\site-packages\torch\utils\cpp_extension.py:316: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
找到cl.exe的路径添加到环境变量path中,去VS安装目录下找exe
D:\VS2019\VC\Tools\MSVC\14.28.29333\bin\Hostx64\x64
重启cmd使环境变量生效
D:\Anaconda\lib\site-packages\torch\utils\cpp_extension.py:209: UserWarning: Error checking compiler version for cl: 'utf-8' codec can't decode byte 0xd3 in position 0: invalid continuation byte
(未测试)安装英文语言包的VS可以解决 https://github.com/harskish/ganspace/issues/31
Pytorch 编译cpp、cuda扩展遇到的问题_xiongxyowo的博客-CSDN博客
找到报错的py文件 cpp_extension.py
找到代码:
compiler_info.decode()
改为
compiler_info.decode('gbk')
但是不想改文件
Pytorch编译maskRCNN问题:cpp_extension.py:189: UserWarning: Error checking compiler version for cl..._高精度计算机视觉的博客-CSDN博客
VS2019可以直接call,说如果输出没有中文
D:\VS2019\VC\Auxiliary\Build>vcvars64.bat
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
将version.py代码从match = self._regex.search(version)更改为match = self._regex.search(str(version))
//…………
经历了安装cuda toolkit版本对应的pytorch…
//…………
UserWarning: It seems that the VC environment is activated but DISTUTILS_USE_SDK is not set.This may lead to multiple activations of the VC env.Please set `DISTUTILS_USE_SDK=1` and try again.
在命令行中执行:set DISTUTILS_USE_SDK=1
File "D:\Anaconda\envs\pcl\lib\site-packages\torch\utils\cpp_extension.py", line 545, in win_cuda_flags
cflags + _get_cuda_arch_flags(cflags))
File "D:\Anaconda\envs\pcl\lib\site-packages\torch\utils\cpp_extension.py", line 1561, in _get_cuda_arch_flags
arch_list[-1] += '+PTX'
IndexError: list index out of range
参考:https://github.com/pytorch/extension-cpp/issues/71
在Python中输出torch.cuda.is_available() 是False,当输出为True时就能够解决这个问题
看了一下我的pytorch安装的是cpu版本的
使用conda search查看包的详细信息
cpu版本的所以会一直返回False
卸载
nvcc -V查看到CUDA是11.2,但是官网没有找到11.2对应的安装命令
https://pytorch.org/get-started/locally/,勇敢安装11.3
至此可以成功创建库
numpy.core.multiarray failed to import
似乎是安装pointnet_lib时安装了其他版本的numpy?还是其他原因?
但是我uninstall之后重新install又可以了,而且安装的还是这个版本
问题解决了就行….
pointnet_utils.py在尝试调用库pointnet_lib时报错
Traceback (most recent call last):
File "
File "
File "
File "
File "
File "H:\PCL\2DKeypoint\model\pointnet_utils.py", line 10, in
from pointnet_lib import pointnet2_utils as futils
ModuleNotFoundError: No module named 'pointnet_lib'
打印sys.path发现是project目录,也就是说,python尝试在project目录下搜索pointnet_lib
因此在代码中,将model目录到sys.path中
pointnet_utils.py中打印__file__显示:
'H:\\PCL\\2DKeypoint\\model\\pointnet_utils.py'
可以使用os.path.dirname(__file__)来获得当前文件的上一层目录
添加
import sys
import os
sys.path.append(os.path.dirname(__file__))
或者
pointnet_utils.py同级目录下创建一个__init__.py文件
import os
import sys
from os.path import join as pjoin
BASEPATH=os.path.dirname(__file__)
sys.path.insert(0,BASEPATH)
sys.path.insert(0,pjoin(BASEPATH,'..'))
sys.path.insert(0,pjoin(BASEPATH,'..','..'))