gpt4 book ai didi

python - Tensorflow GPU 未使用,但明显可用

转载 作者:行者123 更新时间:2023-12-01 06:43:28 34 4
gpt4 key购买 nike

我最近使用过

os.environ["CUDA_VISIBLE_DEVICES"]="-1"

禁用我的 GPU 在 tensorflow 中的使用。但是,当我在终端中使用 unset CUDA_VISIBLE_DEVICES 重新启用它时。下次我运行时出现此错误

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation Conv_1_bn_1/gamma/Initializer/ones: Could not satisfy explicit device specification '' because the node {{colocation_node Conv_1_bn_1/gamma/Initializer/ones}} was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'. All available devices [/job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:XLA_CPU:0].

Root Member(assigned_device_name_index_=-1 requested_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:localhost/replica:0/task:0/device:CPU:0' resource_device_name_='/device:GPU:0' supported_device_types_=[CPU, XLA_CPU] possible_devices_=[]

我知道我的 GPU 可以从

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

返回

.......

incarnation: 351568001108855942
physical_device_desc: "device: XLA_CPU device"
, name: "/device:GPU:0"
device_type: "GPU"
memory_limit: 5729157120
locality {
bus_id: 1
links {
}
}

我还尝试卸载并重新安装tensorflow和tensorflowgpu。我将非常感谢任何和所有的帮助 - 谢谢。

最佳答案

为了解决这个问题,我现在将这行代码放在顶部

sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 1}))

从现在开始我只会使用禁用 GPU

{'GPU': 0}

我强烈建议使用它作为 os.environ 的替代品

关于python - Tensorflow GPU 未使用,但明显可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59347961/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com