
[英]VirtualBox memory exception - std::bad_alloc using TensorFlow and Docker
[英]std::bad_alloc: out_of_memory: CUDA error when importing data/running models
我正在嘗試將數據集上傳到 NVIDA RAPIDS jupyter notebook,但在導入此數據集或在 dask dataframe 上使用 XGBoost 時,此錯誤不斷彈出。訓練數據集的大小為 3.7gb。 我只有一個GPU。
一些規格:
我嘗試使用這個: https://www.kaggle.com/getting-started/140636但我認為這個問題更深入
import cudf
import dask_cudf
import dask_xgboost
import xgboost as xgb
import tensorflow as tf
import torch
!du -sh one-hot-train.csv
> 3.7G one-hot-train.csv
!du -sh y-train.csv
> 10M y-train.csv
# Does not work due to memory issue
X_train = cudf.read_csv('one-hot-train.csv', index_col = 0)
# This will import the data no problem
X_train = dask_cudf.read_csv('one-hot-train.csv', chunksize = "4GB")
X_train = X_train.drop(columns = ['Unnamed: 0'])
# Since the y csv is so small, it doesn't matter how it's imported
y_train = dask_cudf.read_csv('y-train.csv')
y_train = y_train.drop(columns = ['Unnamed: 0'])
xgb_params = {
'learning_rate': 0.3,
'objective': 'binary:logistic',
'tree_method': 'gpu_hist',
'max_depth': 6,
'seed': 555,
'predictor': 'gpu_predictor',
'eval_metric': 'aucpr',
'n_estimators': 5000,
}
# Does not work due to memory issue
xgb_model = dask_xgb.XGBClassifier(**xgb_params)
xgb_model.fit(X_train, y_train)
這是具體的錯誤:
> MemoryError: std::bad_alloc: out_of_memory: CUDA error at: ~/miniconda3/envs/rapids-22.12/include/rmm/mr/device/cuda_memory_resource.hpp
如果您使用單個 GPU,則使用 Dask XGBoost 無濟於事,因為整個數據仍需要適合 memory 以訓練 model。您應該使用具有多個 GPU 的 Dask XGBoost 或使用單個更大的 GPU 來訓練這個 model . XGBoost 為大於內存的數據集訓練提供了一個實驗性的外部 memory 接口, 但它還沒有准備好用於生產。
另外,看起來您正在根據文件名對數據進行單熱編碼。 您無需使用最新版本的 XGBoost 對數據進行單熱編碼。 有關詳細信息,請參閱XGBoost 分類文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.