记录运行gpu错误及解决方案

tensorflow.python.framework.errors_impl.InternalError: Dst tensor is not initialized

解决方案:运行程序之前,先运行export CUDA_VISIBLE_DEVICES=1;如图所示:

最后结果:虽然成功运行,但CPU爆满,GPU使用率为0,没有用到GPU

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.125                Driver Version: 384.125                   |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P100-PCIE...  On   | 00000000:00:0A.0 Off |                    0 |
| N/A   29C    P0    31W / 250W |  15515MiB / 16276MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     25409      C   python                                     15503MiB |
从这里可以看出GPU对应的是0;从这里可以看出15515MiB / 16276MiBGPU的使用率已经接近100%

precess对应的python可以看出是python进程使用了GPU;查看python进程
ps -aux |grep python
root       974  0.0  0.0 573812 13164 ?        Ssl  May17  14:21 /usr/bin/python -Es /usr/sbin/tuned -l -P
root     12269  569 16.7 19581576 10330540 pts/5 Tl 10:10 2427:53 python train.py
root     17625  0.8  0.4 2222036 250196 pts/5  Tl   16:20   0:28 python train.py
root     18895  0.0  0.0 112712   972 pts/6    S+   17:16   0:00 grep --color=auto python
root     25409  375 19.4 44822564 11966148 pts/5 Tl Aug20 7284:52 python train.py

kill python 进程,如图所示:

显示gpu内存使用为0;

原因解析:使用了ctrl+z终止程序;

但结果是仍然占据了极大的显存;

正确的使用方式是ctrl+c终止程序;

其结果是没有占用显存的

通过分析:ctrl+z是挂起程序;ctrl+c是终止程序
 

猜你喜欢

转载自blog.csdn.net/ningyanggege/article/details/81902644