CUDA - numpy related copy error?
import os

import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torchvision.datasets import MNIST
from torchvision import transforms
from sklearn.metrics import accuracy_score
from pytorch_lightning import Trainer
from argparse import ArgumentParser

import pytorch_lightning as pl

input_channel = 1
out_channel = 64
class MNISTModel(pl.LightningModule):

    def __init__(self,parameters):
        super(MNISTModel, self).__init__()
        # not the best model...
        self.params = parameters
        
        self.conv1 = torch.nn.Conv2d(in_channels=1,out_channels=10,kernel_size=3)
        self.pool1 = torch.nn.MaxPool2d(2)

        self.conv2 = torch.nn.Conv2d(in_channels=10,out_channels=20,kernel_size=3)
        self.pool2 = torch.nn.MaxPool2d(2)

        self.conv3 = torch.nn.Conv2d(in_channels=20,out_channels=30,kernel_size=3)
        self.dropout1 = torch.nn.Dropout2d(p=0.25) # probabilit 0.25

        self.fc3 = torch.nn.Linear(30*3*3,270)
        self.fc4 = torch.nn.Linear(270,26)

        self.softmax = torch.nn.LogSoftmax(dim=1)


    def forward(self, x):
        # called with self(x)
        x = F.relu(self.conv1(x))
        x = self.pool1(x)

        x = F.relu(self.conv2(x))
        x = self.pool2(x)

        x = F.relu(self.conv3(x))
        x = self.dropout1(x)
        x = x.view(-1, 30 * 3 * 3) 
        x = F.relu(self.fc3(x))
        x = F.relu(self.fc4(x))
        return self.softmax(x)



    def training_step(self, batch, batch_nb):
        # REQUIRED
        x, y = batch
        y_hat = self.forward(x)
        loss = F.cross_entropy(y_hat, y)
        tensorboard_logs = {'train_loss': loss}
        return {'loss': loss, 'log': tensorboard_logs}

    def validation_step(self, batch, batch_nb):
        # OPTIONAL
        x, y = batch
        y_hat = self.forward(x)
        logits = F.log_softmax(y_hat, dim=1)
        preds = torch.topk(logits, dim=1, k=1)[1].view(-1)
        accuracy = accuracy_score(y,  preds)

        loss = F.cross_entropy(y_hat, y)
        return {'val_loss': loss,
                'accuracy': torch.tensor(accuracy)}

    def validation_epoch_end(self, outputs):
        # OPTIONAL
        avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
        tensorboard_logs = {'val_loss': avg_loss}
        return {'avg_val_loss': avg_loss, 'log': tensorboard_logs}

    def test_step(self, batch, batch_nb):
        # OPTIONAL
        return self.validation_step(batch, batch_nb)


    def test_epoch_end(self, outputs):
        # OPTIONAL
        avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()
        accuracy = torch.stack([x['accuracy'] for x in outputs]).mean()

        logs = {'test_loss': avg_loss, 'test_acc': accuracy}
        return {'avg_val_loss': avg_loss,
                'progress_bar': logs,
                'log': logs}


    def configure_optimizers(self):
        # REQUIRED
        # can return multiple optimizers and learning_rate schedulers
        # (LBFGS it is automatically supported, no need for closure function)
        return torch.optim.Adadelta(self.parameters(), lr=self.params.lr)


    def train_dataloader(self):
        # REQUIRED
        return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32,num_workers=4)

    def val_dataloader(self):
        # OPTIONAL
        return DataLoader(MNIST(os.getcwd(), train=True, download=True, transform=transforms.ToTensor()), batch_size=32,num_workers=4)

    def test_dataloader(self):
        # OPTIONAL
        return DataLoader(MNIST(os.getcwd(), train=False, download=True, transform=transforms.ToTensor()), batch_size=32,num_workers=4)

if __name__ == '__main__':
    args = ArgumentParser()
    args.add_argument('--final_dim', type=int, default=128)
    args.add_argument('--lr', type=float, default=0.02)
    params = args.parse_args()
   
    model = MNISTModel(params)
    trainer = Trainer(weights_save_path=os.getcwd(),gpus=1)
    trainer.fit(model)


Sorry its not exactly a snippet but not sure what seems to be the problem
PyTorch version is 1.1.0
TorchVision version is 0.3.0
Pytorch Lightning version is 0.7.2
Ubuntu 18.4 LTS
Python version is 3.7.3
CUDA Version is 10.2(Nvidia-smi , NVIDIA gt 840m 2GB VRAM)
I can't find what seems to be problem
Validation sanity check:   0%|                                                                                                                                                        | 0/5 [00:00<?, ?it/s]Traceback (most recent call last):
  File "mni.py", line 124, in <module>
    trainer.fit(model)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 705, in fit
    self.single_gpu_train(model)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/distrib_parts.py", line 476, in single_gpu_train
    self.run_pretrain_routine(model)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 844, in run_pretrain_routine
    False)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/evaluation_loop.py", line 262, in _evaluate
    output = self.evaluation_forward(model, batch, batch_idx, dataloader_idx, test_mode)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/pytorch_lightning/trainer/evaluation_loop.py", line 451, in evaluation_forward
    output = model.validation_step(*args)
  File "mni.py", line 69, in validation_step
    accuracy = accuracy_score(y,  preds)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/sklearn/metrics/classification.py", line 176, in accuracy_score
    y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/sklearn/metrics/classification.py", line 72, in _check_targets
    type_true = type_of_target(y_true)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/sklearn/utils/multiclass.py", line 247, in type_of_target
    if is_multilabel(y):
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/sklearn/utils/multiclass.py", line 138, in is_multilabel
    y = np.asarray(y)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/numpy/core/_asarray.py", line 85, in asarray
    return array(a, dtype, copy=False, order=order)
  File "/home/paypaytr/anaconda3/lib/python3.7/site-packages/torch/tensor.py", line 458, in __array__
    return self.numpy()
TypeError: can't convert CUDA tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.