解决RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70&N...

解决两个问题:

(1)RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70

(2)NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

  

之前还好好的代码 时隔一个月就出现了问题

 

haiou@gpu4:/home/gpu4/haiou/newdata/tqa$ cat f2
WARNING:root:WARN: Duplicate embedding found for ;
/home/gpu4/haiou/newdata/tqa/src_0826/layers.py:227: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  alpha_flat = F.softmax(scores.view(-1, y.size(1)))
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=70 error=30 : unknown error
Traceback (most recent call last):
  File "src_0826/main.py", line 129, in 
    b_info,b_dev_acc, b_test_acc = run_epoch(args,model,train_data,dev_data,test_data,checkpoint_path)
  File "src_0826/main.py", line 68, in run_epoch
    model.train(cur_train_data)
  File "/home/gpu4/haiou/newdata/tqa/src_0826/model.py", line 64, in train
    pred_proba = self.network(*feed_input)
  File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/gpu4/haiou/newdata/tqa/src_0826/tmn_v21_update.py", line 101, in forward
    self.mfunction(p_hiddens, q_hiddens, c_hiddens,p_mask, q_mask, c_mask)
  File "/home/gpu4/haiou/newdata/tqa/src_0826/tmn_v21_update.py", line 222, in NA_TriMatching
    x_mask = p_mask)
  File "/home/gpu4/haiou/newdata/tqa/src_0826/tmn_v21_update.py", line 185, in tri_matching
    init_mem = torch.zeros(dim[0],dim[1],dim[2]).float().cuda()  #zero mem
RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70

 询问了实验室的小伙,then发现问题:

gpu4@gpu4:~$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
gpu4@gpu4:~$ nvidia-
nvidia-bug-report.sh           nvidia-container-runtime-hook  nvidia-debugdump               nvidia-installer               nvidia-settings                nvidia-xconfig                 
nvidia-container-cli           nvidia-cuda-mps-control        nvidia-detector                nvidia-modprobe                nvidia-smi                     
nvidia-container-runtime       nvidia-cuda-mps-server         nvidia-docker                  nvidia-persistenced            nvidia-uninstall

然后解决问题:

好吧,兜兜转转后续儿重装,不是安装cuda就相对简单了:

安装NVIDIA驱动程序(如果事先有装但失败的,先卸载,所以要卸载。。)

$ sudo apt remove --purge nvidia*

1)禁用nouveau驱动 
终端中运行:

$ lsmod | grep nouveau

2)关闭图形化界面

$ sudo service lightdm stop

3)安装驱动
NVIDIA驱动安装也有多种方式,runfile文件形式的安装和apt安装

apt安装:

a.添加Graphic Drivers PPA

$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt-get update

寻找合适的驱动版本

$ ubuntu-drivers devices

解决RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70&N..._第1张图片

c.我的显示是415

$ sudo apt-get install nvidia-415

d.安装完成后,重启

$ sudo reboot

e.这时,执行下面的命令,查看驱动的安装状态

$ sudo nvidia-smi

解决RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70&N..._第2张图片

 

查看安装版本:
nvidia-settings --v

参考链接:https://blog.csdn.net/Jonms/article/details/79318566?utm_source=blogxgwz2

你可能感兴趣的:(解决RuntimeError: cuda runtime error (30) : unknown error at /pytorch/aten/src/THC/THCGeneral.cpp:70&N...)