报错:DeviceContextPool
m1858024 发布于2020-06 浏览:5230 回复:6
2
收藏

paddle改写波士顿房价预测代码运行报错,求助。。。

class Regressor(fluid.dygraph.Layer):
    def __init__(self):
        super(Regressor, self).__init__()
        
        # 定义一层全连接层,输出维度是1,激活函数为None,即不使用激活函数
        self.fc = Linear(input_dim=13, output_dim=1, act=None)
    
    # 网络的前向计算函数
    def forward(self, inputs):
        x = self.fc(inputs)
        return x

# 定义飞桨动态图的工作环境
with fluid.dygraph.guard():
    # 声明定义好的线性回归模型
    model = Regressor()
    # 开启模型训练模式
    model.train()
    # 加载数据
    training_data, test_data = load_data()
    # 定义优化算法,这里使用随机梯度下降-SGD
    # 学习率设置为0.01
    opt = fluid.optimizer.SGD(learning_rate=0.01, parameter_list=model.parameters())

Error: Need to Create DeviceContextPool first!
[Hint: pool should not be null.] at (/paddle/paddle/fluid/platform/device_context.h:336)

收藏
点赞
2
个赞
共6条回复 最后由用户已被禁言回复于2022-04
#7回复于2022-03

为啥啊,重启还不好

 

0
#6七年期限回复于2021-03

这个错误确实是重启一下就可以了

0
#5xqisi回复于2021-03

+1  重启就好了

0
#4那夜床摇没摇回复于2020-08

我的也是重启就好了

0
#3lyjiang回复于2020-06

因为你在计算过程中与服务器失去了连接,某些中间变量出错了。需要重启,再次执行。

3
#2回复于2020-06

我当时是重启就好了,也不知道为啥

0
TOP
切换版块