tensorflow - tensorflow 无法识别第二个 GPU (/gpu:1)
问题描述
我正在尝试使用 2 个 GPU,tensorflow 无法识别第二个。第二个 GPU 工作正常(在寡妇环境中)
When I set CUDA_VISIBLE_DEVICES=0 and run the program I see RTX2070 as GPU0
When I set CUDA_VISIBLE_DEVICES=1 and run the program I see GTX1050as GPU0
When I set CUDA_VISIBLE_DEVICES=0,1 and run the program I see RTX2070 as GPU0
所以基本上TF不识别GPU1,它同时一个GPU(GPU 0)有没有手动定义GPU1的命令?
卸载并重新安装,Cudann,python 3.7,tensorflow 和 keras(GPU 版本)。我在 Windows 10 上使用 anaconda。试图将 CUDA_VISIBLE_DEVICES 更改为 0、1。我没有看到任何错误,但第二个 GPU 没有出现在 python 的任何地方。
主 GPU 是 RTX2070 (8GB),第二个 GPU 是 GTX1050 (2GB)。在我提交之前,我花了一些时间寻找解决方案,并尽我所能在互联网上找到。驱动程序是最新的,安装了 64 位版本和最新版本的软件。除了没有出现第二个 GPU 之外,我没有看到任何问题。
这些代码在第一个 GPU 上运行良好,两者都具有 > 3.5 的计算能力。
解决方案
在此处提供解决方案(答案部分),即使它出现在评论部分(感谢 M 学生分享解决方案),以造福社区。
在代码开头添加这个解决了这个问题
import os
os.environ["TF_MIN_GPU_MULTIPROCESSOR_COUNT"]="2"
os.environ["CUDA_VISIBLE_DEVICES"]="0,1"
推荐阅读
- ember.js - 错误:断言失败:您必须向链接组件提供一个或多个参数
- sql-server - SQL Server EXECUTE AS 不当行为
- python - BiLSTM(双向长短期记忆网络)和 MLP(多层感知器)
- amazon-web-services - AWS EC2 默认密码
- sql - 向管道连接添加空格
- tensorflow - 验证准确率达到 90% 后卡住
- python - 如何为图像的每个部分分配像素?
- r - 问题:使用因子的索引来绘制变量
- python - 嵌套 URL - Django-Rest-Framework 无法解析超链接关系的 url
- html - 垂直对齐三个段落