ModuleNotFoundError: No module named ‘torchsparse‘的参考解决方法

写在前面

自己的测试环境:
Ubuntu20.04

一、问题描述

运行python 程序时出现如下报错

ModuleNotFoundError: No module named 'torchsparse'

在这里插入图片描述

二、解决方法

出现上述问题的原因是缺少 torchsparse 导致的。因此需要安装 torchsparse

2.1 方法一:参考官方github链接

  1. 确保至少安装了 PyTorch 1.9.0:
python -c "import torch; print(torch.__version__)"
>>> 1.10.0
  1. 如果您想将 TorchSparse 与 GPU 一起使用,请确保 PyTorch 已安装 CUDA:
python -c "import torch; print(torch.version.cuda)"
>>> 11.3
  1. 然后,通过运行安装脚本即可找到并安装正确的 TorchSparse wheel:
python -c "$(curl -fsSL https://raw.githubusercontent.com/mit-han-lab/torchsparse/master/install.py)"

2.2 方法二:使用指令安装

使用如下指令进行安装:
注意:版本号 v2.1.0 可以修改, 因为官方github中README.md/Installation 中推荐安装 v2.1.0, 并且我自己的电脑 torch.__version__==2.1.2, torch.version.cuda==11.8 (版本都比较高,并且高于官方github中的演示版本),所以我这里也安装 v2.1.0

sudo apt-get install libsparsehash-dev
pip install --upgrade git+https://github.com/mit-han-lab/torchsparse.git@v2.1.0

参考链接

[1] mit-han-lab. torchsparse [EB/OL]. https://github.com/mit-han-lab/torchsparse, 2024-11-13/2024-12-01.
[2] 我是好人BING. torchsparse安装 [EB/OL]. https://blog.youkuaiyun.com/AI_BING_/article/details/124991818, 2023-12-27/2024-12-01.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值