有没有办法纯粹在CPU上运行TensorFlow。我的机器上的所有内存都由运行TensorFlow的单独进程占用。我试图将per_process_memory_fraction设置为0,但未成功。防止TensorFlow访问GPU?
0
A
回答
4
0
您可以通过为0的GPU极限开扩会话中使用的CPU只:
sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
详情请参阅https://www.tensorflow.org/api_docs/python/tf/ConfigProto。
它适用于@Nicolas的证明:
在Python写:
import tensorflow as tf
sess_cpu = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
然后在终端:
nvidia-smi
你会看到类似这样的:
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 24869 C /.../python 99MiB |
+-----------------------------------------------------------------------------+
然后重复过程: 在Python写:
import tensorflow as tf
sess_gpu = tf.Session()
然后在终端:
nvidia-smi
你会看到类似这样的:
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 25900 C /.../python 5775MiB |
+-----------------------------------------------------------------------------+
相关问题
- 1. GPU tensorflow安装问题
- 2. GPU tensorflow运行问题
- 3. 防止图书馆访问
- 4. 防止目录访问
- 5. Tensorflow contrib.learn.Estimator multi-GPU
- 6. TensorFlow Data Starved GPU
- 7. Tensorflow 0.6 GPU Issue
- 8. GPU上的Tensorflow OOM
- 9. Tensorflow-GPU错误 - Pycharm
- 10. Tensorflow:在GPU和CPU
- 11. GPU + CPU Tensorflow训练
- 12. 访问在Tensorflow
- 13. TensorFlow从多个GPU选择GPU使用
- 14. Tensorflow GPU /多GPU如何分配内存?
- 15. 防止进程访问互联网
- 16. 防止更改查询访问
- 17. 如何防止直接访问URL?
- 18. 防止图像直接访问
- 19. 防止Adblock用户访问网站?
- 20. 防止访问处置的参考
- 21. 防止untrusted_app访问数据库
- 22. UI-Router:防止访问父状态
- 23. 如何防止直接访问图像?
- 24. 防止用户访问目录
- 25. 防止直接访问JSON Web服务
- 26. ASP.NET MVC 3路由:防止〜/ home访问?
- 27. 防止访问MVC中的路由4
- 28. 防止通过.htaccess直接访问robots.txt
- 29. PHP:防止直接访问页面
- 30. 防止数据库从外部访问
根据https://github.com/tensorflow/tensorflow/issues/9201目前还不清楚它是否可行。 – npf
我理解它的目的是避免内存分配。如果是这样 - 它会起作用。见上文 – MZHm
从我所了解的情况来看,它确实使用了GPU,即使它没有使用任何内存。我可能是错的,但我相信问题是如何纯粹在CPU上运行TensorFlow。 – npf