[metrics] Accuracy Metric: Tensors must be CUDA and dense
I try the new Accuracy Metric, but it throws error:
Traceback (most recent call last):
  File "main.py", line 139, in <module>
    main(hparams)
  File "main.py", line 69, in main
    trainer.fit(model)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 820, in fit
    self.ddp_train(task, model)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_data_parallel.py", line 502, in ddp_train
    self.run_pretrain_routine(model)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 990, in run_pretrain_routine
    False)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/evaluation_loop.py", line 278, in _evaluate
    output = self.evaluation_forward(model, batch, batch_idx, dataloader_idx, test_mode)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/evaluation_loop.py", line 418, in evaluation_forward
    output = model(*args)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 558, in __call__
    result = self.forward(*input, **kwargs)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/overrides/data_parallel.py", line 96, in forward
    output = self.module.validation_step(*inputs[0], **kwargs[0])
  File "/mnt/lustre/maxiao1/PVM/models/baseline.py", line 374, in validation_step
    acc = self.accuracy(labels_hat, labels)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/metrics/metric.py", line 147, in __call__
    return apply_to_collection(self._orig_call(*args, **kwargs), torch.Tensor,
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/metrics/converters.py", line 59, in new_func
    return func_to_apply(result, *dec_args, **dec_kwargs)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/utilities/apply_func.py", line 26, in apply_to_collection
    return function(data, *args, **kwargs)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/pytorch_lightning/metrics/converters.py", line 244, in _sync_ddp_if_available
    async_op=False)
  File "/mnt/lustre/maxiao1/anaconda3/lib/python3.7/site-packages/torch/distributed/distributed_c10d.py", line 898, in all_reduce
    work = _default_pg.allreduce([tensor], opts)
RuntimeError: Tensors must be CUDA and dense

This is my code:
            pred = pred.view(-1, pred.shape[-1])
            labels = labels.view(-1)
            valid_index = torch.where(labels != -1)
            # select valid part to calculate
            pred = pred[valid_index].contiguous()
            labels = labels[valid_index].contiguous()
            loss = self.loss_fn(pred, labels)
            labels_hat = torch.argmax(pred, dim=1).type_as(labels)
            acc = self.accuracy(labels_hat, labels)

Also have a question, TensorMetric's default reduce_op is SUM, does it automatically calculate average acc?