[windows]pointnet2安装

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 "<frozen importlib._bootstrap>", line 971, in _find_and_load

  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 678, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "H:\PCL\2DKeypoint\model\pointnet_utils.py", line 10, in <module>

    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,'..','..'))

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用和引用的信息来看,"ModuleNotFoundError: No module named 'pointnet2_ops'"是一个Python模块未找到的错误。这个错误通常发生在执行代码时,Python无法找到名为'pointnet2_ops'的模块。 解决这个问题的一个方法是根据引用中提供的安装方法来安装'pointnet2_ops'模块。可以使用以下命令来安装该模块: pip install "git https://github.com/erikwijmans/Pointnet2_PyTorch.git#egg=pointnet2_ops&subdirectory=pointnet2_ops_lib" 安装完成后,再次执行代码应该就不会再出现"ModuleNotFoundError"的错误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [from pointnet2_ops import pointnet2_utils 安装过程](https://blog.csdn.net/goodgoodstudy___/article/details/128338442)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [使用PointRCNN训练自己数据集,ModuleNotFoundError: No module named ‘pointnet2_cuda‘问题](https://blog.csdn.net/weixin_45054427/article/details/130253858)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值