咨询个机器学习PAI问题哈:ev 必须定义在特定的scope下吗?[阿里云机器学习PAI]

咨询个机器学习PAI问题哈:ev 必须定义在特定的scope下吗?ValueError: colocate_vars_with must only be passed a variable created in this tf.distribute.Strategy.scope(), not:
Failed to execute system command. (exit code: 251.)看着是和我用的分布式策略有关系?

distribution = tf.contrib.distribute.ParameterServerStrategy()

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====
1 条回复 A 作者 M 管理员
  1. 是的,目前不支持,如果你仅仅是想把参数放ps,不用这个Strategy也可以的,此回答整理自钉群“DeepRec用户群”

  2. 看起来您正在使用 TensorFlow 参数服务器(Parameter Server)策略,并遇到了“colocate_vars_with 必须只在当前策略作用域中传递变量”的错误。这是因为 TensorFlow 的某些 API 只能在特定的策略作用域中使用,以确保变量在适当的设备上被分配和训练。
    为了修复此问题,您需要确保您的 ev 变量是在 Parameter Server 策略作用域中定义的,如下所示:

    1. 使用 with 语句定义策略作用域:
    with distribution.scope():  # 定义变量  ev = ...
    1. 将 ev 变量分配给适合的设备:
    with distribution.scope():  # 定义变量  ev = ...# 在策略作用域外分配变量ev = distribution.experimental colocate_variables_with(ev)