l79165350
还是想写代码的啊
2019-04-27 23:25

求助:CUDA的RuntimeError:cuda runtime error (30)

5
  • python
  • 神经网络
from torchvision import  models

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

运行后报错:

RuntimeError                              Traceback (most recent call last)
<ipython-input-6-87942ec8aa13> in <module>()
     11 model_ft.fc = nn.Linear(num_ftrs , 5)#############################2
     12 if use_gpu:
---> 13     model_ft = model_ft.cuda()
     14 #criterion = nn.MultiMarginLoss()
     15 criterion = nn.CrossEntropyLoss()

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in cuda(self, device)
    258             Module: self
    259         """
--> 260         return self._apply(lambda t: t.cuda(device))
    261 
    262     def cpu(self):

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _apply(self, fn)
    185     def _apply(self, fn):
    186         for module in self.children():
--> 187             module._apply(fn)
    188 
    189         for param in self._parameters.values():

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in _apply(self, fn)
    191                 # Tensors stored in modules are graph leaves, and we don't
    192                 # want to create copy nodes, so we have to unpack the data.
--> 193                 param.data = fn(param.data)
    194                 if param._grad is not None:
    195                     param._grad.data = fn(param._grad.data)

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in <lambda>(t)
    258             Module: self
    259         """
--> 260         return self._apply(lambda t: t.cuda(device))
    261 
    262     def cpu(self):

~\Anaconda3\lib\site-packages\torch\cuda\__init__.py in _lazy_init()
    160             "Cannot re-initialize CUDA in forked subprocess. " + msg)
    161     _check_driver()
--> 162     torch._C._cuda_init()
    163     _cudart = _load_cudart()
    164     _cudart.cudaGetErrorName.restype = ctypes.c_char_p

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

Win10+Anaconda5.0.1+python3.6.3
Cuda driver version 10.1
Cuda Toolkit 10.1
pytorch 1.0.1
显卡GeForce GTX 1050 Ti
nvidia驱动版本430.39

求助啊!!!

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答