阻止 TensorFlow 访问 GPU? [英] Prevent TensorFlow from accessing the GPU?

查看:27
本文介绍了阻止 TensorFlow 访问 GPU?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法完全在 CPU 上运行 TensorFlow.我机器上的所有内存都被一个运行 TensorFlow 的单独进程占用.我曾尝试将 per_process_memory_fraction 设置为 0,但未成功.

Is there a way to run TensorFlow purely on the CPU. All of the memory on my machine is hogged by a separate process running TensorFlow. I have tried setting the per_process_memory_fraction to 0, unsuccessfully.

推荐答案

看看这个问题或这个答案.

总而言之,您可以添加这段代码:

To summarise you can add this piece of code:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
import tensorflow as tf

使用 CUDA_VISIBLE_DEVICES 环境变量是 之一如果不是安装了 GPU-tensorflow 并且不想使用任何 GPU 的方法.

Playing with the CUDA_VISIBLE_DEVICES environment variable is one of if not the way to go whenever you have GPU-tensorflow installed and you don't want to use any GPUs.

您希望 export CUDA_VISIBLE_DEVICES= 或在 TensorFlow 的非 GPU 安装中使用 virtualenv.

You to want either export CUDA_VISIBLE_DEVICES= or alternatively use a virtualenv with a non-GPU installation of TensorFlow.

这篇关于阻止 TensorFlow 访问 GPU?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆