【问题标题】:StyleGAN image generation doesn't work, TensorFlow doesn't see GPUStyleGAN 图像生成不起作用,TensorFlow 看不到 GPU
【发布时间】:2020-03-30 15:24:28
【问题描述】:

重新安装 Ubuntu 18.04 后,我无法再使用 StyleGAN 代理生成图像。我得到的错误信息是InvalidArgumentError: Cannot assign a device for operation Gs_1/_Run/Gs/latents_in: {{node Gs_1/_Run/Gs/latents_in}}was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:XLA_CPU:0, /job:localhost/replica:0/task:0/device:XLA_GPU:0 ]. Make sure the device specification refers to a valid device.

我有 CUDA 10.1,我的驱动程序版本是 418.87。 conda 环境的 yml 文件可用here。我使用 pip 安装了 tensorflow-gpu==1.14。

Hereyopu 可以找到我用来生成图像的 jupyter notebook。

如果我按照建议使用命令检查可用资源

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

我得到了答案

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 7185754797200004029
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 18095173531080603805
physical_device_desc: "device: XLA_GPU device"
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 10470458648887235209
physical_device_desc: "device: XLA_CPU device"
]

非常欢迎任何有关如何解决此问题的建议!

【问题讨论】:

    标签: python tensorflow machine-learning gpu


    【解决方案1】:

    可能是因为 TensorFlow 正在寻找 GPU:0 来分配设备进行操作,而您的图形单元的名称实际上是 XLA_GPU:0

    您可以尝试在打开会话时使用软放置,以便 TensorFlow 在运行时使用任何现有的 GPU(或任何其他支持的设备,如果不可用):

    #  using allow_soft_placement=True
    se = tf.Session(config=tf.ConfigProto(allow_soft_placement=True))
    

    【讨论】:

    • 感谢您的提示。不幸的是,这并没有解决问题。
    • 对不起!您是否尝试过将 TensorFlow 降级到旧版本以检查问题是否来自此?
    • 我尝试使用 tensorfflow-gpu==1.12 但没有帮助。
    • 对不起!现在看了一堆关于这个问题的东西,你是否也尝试过安装 cuDNN (docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html)?
    • 好的!如果你使用的是 conda 环境,GitHub 上的一些人建议卸载 TensorFlow 的 pip 版本(pip uninstall tensorflow-gpu),然后安装 conda 版本(conda install -c anaconda tensorflow-gpu)。你也试过吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-09
    • 1970-01-01
    • 2018-03-14
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多