首页 > 解决方案 > StyleGAN2 在 Colab 中获取返回不兼容设备分配 GPU 与 CPU 的常量层的值

问题描述

我正在尝试使用带有 GPU 运行时的 Google Colab 中的以下代码获取 StyleGAN 生成器常量层的值

v1 = (tflib.run(['G_synthesis_1/4x4/Const/const:0'])[0])

但我收到以下错误:

> InvalidArgumentError: Cannot place the graph because a reference or
> resource edge connects colocation groups with incompatible assigned
> devices: /job:localhost/replica:0/task:0/device:GPU:0 vs
> /job:localhost/replica:0/task:0/device:CPU:0. The edge src node is
> G_synthesis_1/4x4/Const/const , and the dst node is
> _retval_G_synthesis_1/4x4/Const/const_0_0

这是错误粘贴箱

这是我试图复制的参考代码。笔记本的运行时类型设置为 GPU,所以我假设代码将在其上运行。是否可以在 Colab 中运行它?

标签: pythontensorflowgoogle-colaboratorynvidiastylegan

解决方案


推荐阅读