Comments (5)
Update
I remove all .dense() in-betweens in forward function and the speed becomes normal.
So if I transfer a sparse tensor to dense like the following example, the time cost of middle_conv_block2 would be increased. The dense() return an inference of ret1 and turn ret1 into dense format inplace, which lead to an dense input for next sparse convolution?
def forward(self, voxel_features, coors, batch_size):
coors = coors.int()
ret0 = spconv.SparseConvTensor(voxel_features, coors, self.sparse_shape, batch_size)
ret1 = self.middle_conv_block1(ret0)
ret1_dense = ret1.dense()
ret2 = self.middle_conv_block2(ret1)
return ret2
from spconv.
dense
isn't a inplace operation, it convert sparse tensor to regular torch dense tensors without modify origin sparse tensor, this operation use pure pytorch implementation and may cost lots of time, check spconv/__init__.py for more details.
So the time cost increase shouldn't happen. How do you measure time? do you add torch.cuda.synchronize()
?
from spconv.
Nope. But I test the time outside the forward function.
Like
start = time.time()
out=model(input)
end=time.time()
print end-start
torch.cuda.synchronize() would affect this duration a lot?
Anyway, the time cost becomes much less after I remove all dense() operations. I guess the dense operations is time costly.
from spconv.
you must use torch.cuda.synchronize() to measure device code time:
torch.cuda.synchronize()
t = time.time()
# device code
torch.cuda.synchronize()
print(time.time() - t)
otherwise the measured time is wrong.
from spconv.
@traveller59
I followed your instructions and got the same results.
That is, with .dense() operations in-betweens, the time cost is around 200ms:
0.196189165115
0.204177856445
while, without (comment out) .dense() operations in-betweens, the time cost is around 70-90ms:
0.0651390552521
0.0862791538239
The example code is as follows:
def forward(self, voxel_features, coors, batch_size):
coors = coors.int()
ret0 = spconv.SparseConvTensor(voxel_features, coors, self.sparse_shape, batch_size)
# ret0_dense = ret0.dense()
torch.cuda.synchronize()
t = time.time()
ret1 = self.middle_conv_block1(ret0) ## SparseSequential
ret1_dense = ret1.dense()
ret2 = self.middle_conv_block2(ret1) ## SparseSequential
ret2_dense = ret2.dense()
ret3 = self.middle_conv_block3(ret2) ## SparseSequential
ret3_dense = ret3.dense()
ret4 = self.middle_conv_block4(ret3) ## SparseSequential
ret4_dense = ret4.dense()
ret5 = self.middle_conv_block5(ret4) ## SparseSequential
ret5_dense = ret5.dense()
ret6 = self.middle_conv_block6(ret5) ## SparseSequential
print time.time() - t
return ret6.dense()
from spconv.
Related Issues (20)
- How to get FLOPs when using spconv 2.x? HOT 2
- ERROR: No matching distribution found for spconv-cu114 HOT 1
- import spconv.pytorch will slow down torch.multiprocessing.Pool().apply_async()
- How to visualise spconv HOT 3
- About the usage of sparse_add
- Really Annoying for trying to understand spconv2d, will you please give us a detailed example on the input of [4,3,128,128] (NCHW) up channel to (4,16,128,128) ) HOT 1
- How to Build backward for Sparse tensor dot Multiplication
- spconv could not take advantage of gpu acceleration
- Discrepancy Between Sparse and Dense Convolution Outputs for Density=1.0
- Data exceed int32 range HOT 1
- I spent 4 days trying to compile the C++ library of this library, and this is the only solution that worked. HOT 4
- SparseGlobalAvgPool seems not working
- May I help with maintaining PyPI of spconv and cumm
- [How to] 3D Convs with batch size = 1, Inverse 3D Convs with batch size = N
- Point Cloud Sparse Tensor error with SubMConv3dLayer: SubMmerge_sort: failed on 2nd step: cudaErrorIllegalAddress: an illegal memory access was encountered HOT 1
- how to align the order of indices HOT 1
- Is there any function that works the same as MinkowskiEngine pruning here?
- Cuda Illegal Memory 700 Error
- conv3d after .dense() function HOT 1
- IndexError: tensors used as indices must be long, byte or bool tensors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spconv.