Jupyter笔记本随机停止使用所有CPU内核

问题描述 投票:2回答:1

我目前正在做一个简单的回归任务(没有涉及ML库,只有我自己的代码)来完成家庭作业。问题是Jupyter有时使用95%以上的CPU(这很好,我有8600k我想使用)但是经常决定不使用任何额外的线程并保持稳定的20%使用率。由于这个原因,我的反馈循环增加了6倍。

我四处寻找任何可能相关但没有发现的jupyter相关设置。这个问题有什么解释吗?

编辑:这是我目前正在使用的代码。传递的数据是30000x36 np阵列。我不知道jupyter与此类似,但嘿,它有时会这样做。

def hyp(theta, X):
    return X.dot(theta)

def cost_function(theta,X,Y):
    return (1.0 / ( 2 * X.shape[0] ) )  * np.sum(  (hyp(theta, X) - Y ) ** 2 ) 


def derivative_cost_function(theta, X, Y):
    e = hyp(theta, X) - Y
    return (1.0 / X.shape[0]) * X.T.dot(e)


def GradientDescent(X, Y, maxniter=400000):

    nexamples = float(X.shape[0])

    thetas = np.ones(X.shape[1],)
    alpha = 0.001

    print("Before:", cost_function(thetas, X, Y))

    print_iter = 100
    for i in range (maxniter):

        dtheta = derivative_cost_function(thetas, X, Y)
        thetas = thetas - alpha * dtheta

        if i % print_iter == 0:
            print(i, cost_function(thetas, X, Y))

    print("After:", cost_function(thetas, X, Y))
    return thetas
python-3.x multithreading jupyter-notebook linear-regression cpu-usage
1个回答
1
投票

这看起来更像是一个愚蠢的问题,而不是一个jupyter问题。看看https://roman-kh.github.io/numpy-multicore/,让numpy使用更多内核。

© www.soinside.com 2019 - 2024. All rights reserved.