RuntimeError: CUDA error: unknown error

在利用python main.py运行程序的时候出现以下bug:

RuntimeError: CUDA error: unknown error

Traceback (most recent call last):
  File "main.py", line 296, in 
    main()
  File "main.py", line 140, in main
    model = model.cuda()
  File "/usr/local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 258, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/usr/local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 185, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 191, in _apply
    param.data = fn(param.data)
  File "/usr/local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 258, in 
    return self._apply(lambda t: t.cuda(device))
RuntimeError: CUDA error: unknown error

解决方法

sudo python main.py

问题得到解决,但是如果要使用pycharm进行调试,这样子显然是行不通的,因为pycharm下以管理员身份进行运行程序是比较麻烦的,虽然也有人给出了解决方案(本人没有试过)@https://www.cnblogs.com/wangxiaotao/p/8645377.html

还是从根本上查找自己程序中的问题

 

你可能感兴趣的:(Python)