记录一个在服务器上使用tensorflow-gpu报错的debug过程
总结
碰到如下两个错误:
1. Internal: failed initializing StreamExecutor for CUDA device ordinal 1: Internal: failed call to cuDevicePrimaryCtxRetain: CUDA_ERROR_UNKNOWN: unknown error——(不设置os或者是os设置了多张显卡VISIBLE并且包含问题显卡时报该错误)
2. RuntimeError: CUDA runtime implicit initialization on GPU:0 failed. Status: all CUDA-capable devices are busy or unavailable——(os只设置了问题显卡VISIBLE时报该错误)
并且确定GPU没有被占满,理应是可以用的,于是利用 os.environ['CUDA_VISIBLE_DEVICES'] 逐张显卡测试,最终发现当'1'号GPU是VISIBLE的时候就会报错。
初步判定问题为GPU出了问题
解决方法:利用 os.environ['CUDA_VISIBLE_DEVICES'] 避开出问题的显卡。当不设置该参数的时候程序默认是可以看到所有显卡,自然会看到出问题的卡而导致程序报错。
具体整个tensorflow配置过程以及debug过程
conda的镜像源设置如下(北外的镜像源,亲测十分好用):
<