Closed michalSkoury closed 10 months ago
Thanks for reporting this issue! Could you manually install rootpath
? We will add that into our dependency.
Thanks The installation works now but i can't seem to use the generative=True option I define the model:
from torchsparse import nn as spnn import torch.nn as nn class MyModel(nn.Module): def init(self, inc, outc, ks=3, stride=1, relu=True): super().init() self.net = nn.Sequential( spnn.Conv3d(inc, outc, kernel_size=ks, stride=stride, transposed=True, generative=True, ), spnn.BatchNorm(outc), spnn.ReLU(relu))
def forward(self, x): out= self.net (x) return out
I get the foloowing error when trying to forward the model:
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "torchsparse/nn/modules/conv.pyx", line 99, in torchsparse.nn.modules.conv.Conv3d.forward File "torchsparse/nn/functional/conv/conv.pyx", line 157, in torchsparse.nn.functional.conv.conv.conv3d File "torchsparse/nn/functional/conv/kmap/build_kmap.pyx", line 80, in torchsparse.nn.functional.conv.kmap.build_kmap.build_kernel_map ValueError: Unsupported downsample mode: spconv for kmap_mode: hashmap_on_the_fly (please switch to downsample_mode=spconv).
Hi @michalSkoury. Could you please add the following code before forwarding the model?
from torchsparse.nn import functional as F
F.set_kmap_mode('hashmap')
If there is still an error, please feel free to reach out!
Did i also need to change someting on my regular convs? I just noticed that when using stride>1 with transposed=False, generative=False, i get an empty result:
from torchsparse import nn as spnn import torch.nn as nn class MyModel(nn.Module): def init(self, inc, outc, ks=3, relu=True): super().init() self.net = nn.Sequential( spnn.Conv3d(inc, outc, kernel_size=ks, stride=2, transposed=False, generative=False, ), spnn.BatchNorm(outc), spnn.ReLU(relu))
def forward(self, x): conv1= self.net (x) return conv1
I get the folowing:
** Note that before using this wheel version i didn't have this issue (using the same input)
Did i also need to change someting on my regular convs? I just noticed that when using stride>1 with transposed=False, generative=False, i get an empty result:
from torchsparse import nn as spnn import torch.nn as nn class MyModel(nn.Module): def init(self, inc, outc, ks=3, relu=True): super().init() self.net = nn.Sequential( spnn.Conv3d(inc, outc, kernel_size=ks, stride=2, transposed=False, generative=False, ), spnn.BatchNorm(outc), spnn.ReLU(relu))
def forward(self, x): conv1= self.net (x) return conv1
I get the folowing:
** Note that before using this wheel version i didn't have this issue (using the same input)
Hi @michalSkoury. You don't need to change the setting of conv layers. However, you may need to change the definition of your input coordinates from [x, y, z, batch] to [batch, x, y, z]. Please refer to our document for details.
Hey so i missed the part where i needed to change the coordinates and aftrer fixing it i do get the same reults in regular convolotion with the previous and the new version. However im still having issues with the generative option. I did add F.set_kmap_mode('hashmap') as you suggested and installed rootpath and now i get the foloowing error: return forward_call(*input, **kwargs) File "torchsparse/nn/modules/conv.pyx", line 99, in torchsparse.nn.modules.conv.Conv3d.forward File "torchsparse/nn/functional/conv/conv.pyx", line 157, in torchsparse.nn.functional.conv.conv.conv3d File "torchsparse/nn/functional/conv/kmap/build_kmap.pyx", line 131, in torchsparse.nn.functional.conv.kmap.build_kmap.build_kernel_map File "torchsparse/nn/functional/conv/kmap/func/hashmap.pyx", line 33, in torchsparse.nn.functional.conv.kmap.func.hashmap.build_kmap_implicit_GEMM_hashmap File "torchsparse/nn/functional/conv/kmap/upsample.pyx", line 26, in torchsparse.nn.functional.conv.kmap.upsample.spupsample_generative TypeError: Argument 'device' has incorrect type (expected str, got torch.device)
@michalSkoury Could you provide more information about how did you run the generative conv? I tried the following code but didn't met the error you mentioned.
from torchsparse import nn as spnn
from torchsparse import SparseTensor
import torch
import torch.nn as nn
class MyModel(nn.Module):
def __init__(self, inc, outc, ks=3, stride=1, relu=True):
super().__init__()
self.net = nn.Sequential(
spnn.Conv3d(inc,
outc,
kernel_size=ks,
stride=stride,
transposed=True,
generative=True,
),
spnn.BatchNorm(outc),
spnn.ReLU(relu))
def forward(self, x):
out= self.net(x)
return out
if __name__ == "__main__":
from torchsparse.nn import functional as F
F.set_kmap_mode('hashmap')
F.set_downsample_mode('minkowski')
model = MyModel(inc = 16, outc = 32).cuda()
num_of_points = 1000
feats = torch.rand((num_of_points, 16)).cuda()
coords = torch.randint(0, 5, (num_of_points, 4))
coords[:,0] = 0 # Batch index
coords = coords.to(torch.int32).cuda()
input = SparseTensor(coords=coords, feats=feats).cuda()
output = model(input)
print(output.C)
print(output.F)
Yes, to reproduce just run your code with stride=2
Hi @michalSkoury! Thanks for the clarification! We have fixed that error. Could you please try to reinstall torchsparse 2.1.0 through python -c "$(curl -fsSL https://raw.githubusercontent.com/mit-han-lab/torchsparse/master/install.py)"
?
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-auth 2.21.0 requires urllib3<2.0, but you have urllib3 2.0.4 which is incompatible. numba 0.57.1 requires numpy<1.25,>=1.21, but you have numpy 1.25.2 which is incompatible. tensorflow 2.13.0 requires numpy<=1.24.3,>=1.22, but you have numpy 1.25.2 which is incompatible. tensorflow 2.13.0 requires typing-extensions<4.6.0,>=3.6.6, but you have typing-extensions 4.7.1 which is incompatible. Successfully installed backports.cached-property-1.0.2 blessings-1.7 cachetools-5.3.1 certifi-2023.7.22 chardet-5.2.0 charset-normalizer-3.2.0 codecov-2.1.13 colorama-0.4.6 coloredlogs-15.0.1 colour-runner-0.1.1 coverage-7.2.7 deepdiff-6.3.1 distlib-0.3.7 filelock-3.12.2 humanfriendly-10.0 idna-3.4 numpy-1.25.2 ordered-set-4.1.0 packaging-23.1 platformdirs-3.10.0 pluggy-1.2.0 pygments-2.15.1 pyproject-api-1.5.3 requests-2.31.0 rootpath-0.1.1 six-1.16.0 termcolor-2.3.0 tomli-2.0.1 torchsparse-2.1.0+torch113cu117 tox-4.6.4 tqdm-4.65.0 typing-extensions-4.7.1 urllib3-2.0.4 virtualenv-20.24.2 wheel-0.41.0 (deepl) vico@vico-Robo:~/下载$ pip uninstall torchsparse
i use command “python -c "$(curl -fsSL https://raw.githubusercontent.com/mit-han-lab/torchsparse/master/install.py)"” to install it. my numpy versionn is 1.23.0 ,this command will update it to 1.25. although i degrade the numpy and typing-extensions . from torchsparse.tensor import PointTensor doesn't work my environment CUDA 11.7 PyTorch 2.0.1. GPU 3060 Ubuntu 22.04 python 3.10
i try to install another version of the torchsparse 2.0.0 use install.bash . it seem does not work too.
bash install.sh
Looking in indexes: https://pypi.hanlab.ai/simple
ERROR: Could not find a version that satisfies the requirement torchsparse==2.0.0+torch20cu117 (from versions: none)
ERROR: No matching distribution found for torchsparse==2.0.0+torch20cu117
@ys-2020, could you please take a look at the issue that @vico1999-ros mentioned when you have time? Thanks!
Hi @vico1999-ros . Sorry for the late response. The pip's dependency error not necessarily leads to the failure of TorchSparse installation. If you can still import torchsparse
in your Python environment, that would be fine.
Also, we do not have PointTensor
in TorchSparse v2.1.0. Please try to use from torchsparse import SparseTensor
instead.
For TorchSparse 2.0.0, we do not provide pypi wheels currently. If you want to use TorchSparse 2.0.0, you can build it from source. (Clone the code here and use pip install -r requirements.txt
and python setup.py install
.)
Is there an existing issue for this?
Have you followed all the steps in the FAQ?
Current Behavior
After installing the new wheel, import doesn't owrk:
from torchsparse import SparseTensor File "torchsparse/init.pyx", line 6, in init torchsparse.init File "torchsparse/utils/tune.pyx", line 15, in init torchsparse.utils.tune File "torchsparse/nn/init.pyx", line 2, in init torchsparse.nn.init File "torchsparse/nn/modules/init.pyx", line 4, in init torchsparse.nn.modules.init File "torchsparse/nn/modules/conv.pyx", line 17, in init torchsparse.nn.modules.conv File "torchsparse/nn/functional/init.pyx", line 3, in init torchsparse.nn.functional.init File "torchsparse/nn/functional/conv/init.pyx", line 5, in init torchsparse.nn.functional.conv.init File "torchsparse/nn/functional/conv/conv_config.pyx", line 4, in init torchsparse.nn.functional.conv.conv_config File "torchsparse/nn/functional/conv/utils/init.pyx", line 2, in init torchsparse.nn.functional.conv.utils.init File "torchsparse/nn/functional/conv/utils/private_attribute_dict.pyx", line 6, in init torchsparse.nn.functional.conv.utils.private_attribute_dict ModuleNotFoundError: No module named 'rootpath'
Error Line
from torchsparse import SparseTensor
Environment
Full Error Log
Error Log
[PUT YOUR ERROR LOG HERE]