scikit-learn - 使用多个GPU的GridSearchCV中 "n_jobs == 1"的含义

标签 scikit-learn keras

我一直在使用带有 4 个 NVIDIA GPU 的 Keras 框架来训练 NN 模型。 (数据行数:~160,000,列数:5)。现在我想通过使用 GridSearchCV 来优化它的参数。

但是,每当我尝试将 n_jobs 更改为 1 以外的其他值时,我都会遇到几个不同的错误。错误,例如

CUDA OUT OF MEMORY
Can not get device properties error code : 3

然后我读了这个网页,
“#如果你不使用 GPU,你可以将 n_jobs 设置为 1 以外的值”
http://queirozf.com/entries/scikit-learn-pipeline-examples

那么在 GridSearchCV 中使用多个 GPU 是不可能的吗?

[环境]
Ubuntu 16.04
python 3.6.0
Keras/Scikit-Learn

谢谢!

最佳答案

根据 scikit learn 中的常见问题解答 - 不支持 GPU。 Link

您可以使用 n_jobs使用您的 CPU 内核。如果您想以最大速度运行,您可能需要使用几乎所有的内核:

import multiprocessing
n_jobs = multiprocessing.cpu_count()-1

关于scikit-learn - 使用多个GPU的GridSearchCV中 "n_jobs == 1"的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52148562/

相关文章:

python - 值错误 : A value in x_new is below the interpolation range

python - 安装sklearn时出错

python - 使用 SVM 的 coef_ 函数的特征重要性

python - Tensorflow 2.0 - 属性错误 : module 'tensorflow' has no attribute 'Session'

python - Keras 功能 API : "Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (X, Y)"

python - 测试准确率较低但 AUC 分数较高的可能原因

python - 在一个对象中处理标签编码、转换和估计

python - model.predict() 返回类而不是概率

python - 如何在带有tensorflow v2.x后端的keras中加载带有tensorflow v1.x后端的keras模型?

python - 在 Tensorflow 2.0 中的简单 LSTM 层之上添加 Attention