CUDA RuntimeError:cuda runtime error (30)

created at 06-26-2021 views: 5

description

source code:

from torchvision import  models
use_gpu = torch.cuda.is_available()
model_ft = models.resnet18(pretrained = True)
if use_gpu:
    model_ft = model_ft.cuda()   

error message:

RuntimeError: cuda runtime error (30) : unknown error at ..\aten\src\THC\THCGeneral.cpp:87

Possible solutions

1.  add:

import torch
torch.cuda.current_device()
torch.cuda._initialized = True

2. if you installed IPython, then try reinstall ipython

pip uninstall ipython
pip install ipython

3. kill some processes

first check the graphics driver nvidia-smi to check if the graphics driver is OK. 

with command fuser -v /dev/nvidia*
You can see the video memory occupied by the PID process, you kill several processes.
Or just reboot the machine

created at:06-26-2021
edited at: 06-26-2021: