我正在使用tensorflow-gpu。我想使用GTX1070,但tensorflow-gpu使用我的CPU。我不知道该怎么办。
我使用 CUDA 9.0 和 CUDNN 7.1.4。我的tensorflow-gpu版本是1.9。
在官网运行此命令后
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-07-30 10:53:43.369025: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2018-07-30 10:53:43.829922: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties: name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.683 pciBusID: 0000:01:00.0 totalMemory: 8.00GiB freeMemory: 6.63GiB 2018-07-30 10:53:43.919043: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 1 with properties: name: GeForce GTX 1050 major: 6 minor: 1 memoryClockRate(GHz): 1.455 pciBusID: 0000:05:00.0 totalMemory: 2.00GiB freeMemory: 1.60GiB 2018-07-30 10:53:43.926001: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1456] Ignoring visible gpu device (device: 1, name: GeForce GTX 1050, pci bus id: 0000:05:00.0, compute capability: 6.1) with Cuda multiprocessor count: 5. The minimum required count is 8. You can adjust this requirement with the env var TF_MIN_GPU_MULTIPROCESSOR_COUNT. 2018-07-30 10:53:43.934810: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0 2018-07-30 10:53:44.761551: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-07-30 10:53:44.765678: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958] 0 1 2018-07-30 10:53:44.768363: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: N N 2018-07-30 10:53:44.771773: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 1: N N 2018-07-30 10:53:44.774913: I T:\src\github\tensorflow\tensorflow\co
enter code here
re\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6395 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000enter code here
:01:00.0, compute capability: 6.1)
最佳答案
正如我从 tensorflow 引擎的日志摘录中看到的 - 它使用 GPU 设备 0
(/job:localhost/replica:0/task:0/device:GPU:0 with 6395 MB memory) -> physical
GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute
capability: 6.1)
但拒绝使用您的 GeForce GTX 1050。这是可能的,因为环境变量 TF_MIN_GPU_MULTIPROCESSOR_COUNT 似乎设置为 8。
尝试按照之前日志中的建议将其设置为值 5:
设置 TF_MIN_GPU_MULTIPROCESSOR_COUNT=5
如果您想确定使用的是哪个设备 - 使用
初始化 sessionsess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
您可以在 Using GPUs tensorflow 上阅读更多内容文档页面
关于tensorflow - 虽然pc识别gpu,但它使用的是tensorflow-gpu中的CPU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51586121/