How to use PointToVoxel on GPU?
I've noticed the WARNING: you MUST construct PointToVoxel AFTER set device. in class PointToVoxel in /spconv/pytorch/utils.py.
What can i do to change the previous code which was written for VoxelGenerator to suit for PointToVoxel? It is running on cpu and the memory is no enough at all.
init PointToVoxel after dataloader multiprocessing
class VoxelGen():
def __init__(*args):
self._is_init = False
def init():
self._is_init = True
self.point2voxel = PointToVoxel(.....)
def __call__(points):
if not self._is_init:
self.init()
return self.point2voxel(points)
init PointToVoxel after dataloader multiprocessing
def transform_points_to_voxels(self, data_dict=None, config=None, voxel_generator=None):
if data_dict is None:
voxel_generator = VoxelGen(
vsize_xyz=config.VOXEL_SIZE,
coors_range_xyz=self.point_cloud_range,
num_point_features=config.NUM_POINT_FEATURES,
max_num_points_per_voxel=config.MAX_POINTS_PER_VOXEL,
max_num_voxels=config.MAX_NUMBER_OF_VOXELS[self.mode],
device=torch.device('cuda')
)
grid_size = (self.point_cloud_range[3:6] - self.point_cloud_range[0:3]) / np.array(config.VOXEL_SIZE)
self.grid_size = np.round(grid_size).astype(np.int64)
self.voxel_size = config.VOXEL_SIZE
return partial(self.transform_points_to_voxels, voxel_generator=voxel_generator)
points = data_dict['points']
points = torch.from_numpy(points).to(torch.device("cuda"))
voxel_output = voxel_generator(points)
.........
I used it in pcdet/datasets/processor/data_processor.py but the bug RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method still occurrs. What might the problem be?