Tensorflow不能使用GPU的解决办法

服务器在训练模型,另一边我在瞎胡乱搞不晓得咋个搞的,就不能使用GPU了。
python3.6下

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

查询了一下确实检测不到GPU了,只有CPU。
随后使用
pip list
pip3 list
都查询了一下版本也都正常
tensorflow和tensorflow-GPU都是1.12.0版本的(如果想使用GPU则tensorflow-gpu的版本一定不能比tensorflow的版本低)
另外也没有安装tf-lights之类的(之前被坑过)

最后打算卸载原有的tensorflow重新安装来解决。
踩了很多坑,也尝试过强制安装TF的方法,最后还是不行。
最后怀疑是没有卸载干净,又完完全全的卸载了一遍,最后得以解决

sudo pip uninstall protobuf #对应自己的安装方式进行卸载
sudo pip3 uninstall protobuf
pip3 uninstall protobuf
pip uninstall protobuf

sudo pip uninstall tensorflow
sudo pip3 uninstall tensorflow
pip uninstall tensorflow
pip3 uninstall tensorflow

sudo pip uninstall tensorflow-gpu
sudo pip3 uninstall tensorflow-gpu
pip uninstall tensorflow-gpu
pip3 uninstall tensorflow-gpu

最后重新安装tensorflow-gpu即可 #不需要安装CPU版本的tensorflow

sudo pip install tensorflow-gpu #1.12.0版本(与我的CUDA,cudnn版本对应)
pip install tensor2tensor[tensorflow_gpu] #我用的这个

更新一下:
使用清华源快速安装tensorflow(满速)

sudo pip3 install tensorflow-gpu==1.12.0 -i https://pypi.tuna.tsinghua.edu.cn/simple #可改成任意版本
全部评论

相关推荐

10-22 12:03
山东大学 Java
程序员小白条:26届一般都得有实习,项目可以随便写的,如果不是开源社区的项目,随便包装,技术栈也是一样,所以本质应该找学历厂,多投投央国企和银行,技术要求稍微低一点的,或者国企控股那种,纯互联网一般都得要干活
应届生简历当中,HR最关...
点赞 评论 收藏
分享
牛牛不会牛泪:脉脉太多这种了,纯水军
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务