Skip to content

Commit feadab8

Browse files
xgb模型取消gpu模式:部分机器或集群可能由于没有gpu导致运行失败.
1 parent c3b75de commit feadab8

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

autox/models/classifier.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, params=None, n_fold=10):
3333
'reg_alpha': 40,
3434
'reg_lambda': 18,
3535
'min_child_weight': 16,
36-
'tree_method': 'gpu_hist'
36+
# 'tree_method': 'gpu_hist'
3737
}
3838
if params is not None:
3939
self.params_ = params
@@ -56,7 +56,7 @@ def objective(trial):
5656
'reg_lambda': trial.suggest_int('reg_lambda', 5, 100),
5757
'min_child_weight': trial.suggest_int('min_child_weight', 5, 20),
5858
}
59-
reg = xgb.XGBClassifier(tree_method='gpu_hist', **param_grid)
59+
reg = xgb.XGBClassifier(**param_grid) # tree_method='gpu_hist',
6060
reg.fit(X_train, y_train,
6161
eval_set=[(X_valid, y_valid)], eval_metric='auc',
6262
verbose=False)
@@ -79,7 +79,7 @@ def objective(trial):
7979

8080
self.params_ = trial.params
8181
self.params_['eta'] = 0.01
82-
self.params_['tree_method'] = 'gpu_hist'
82+
# self.params_['tree_method'] = 'gpu_hist'
8383

8484
def fit(self, X, y, tuning=True, Debug=False):
8585
log(X.shape)

autox/models/regressor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def __init__(self, metric, params=None, n_fold=10):
139139
'reg_alpha': 40,
140140
'reg_lambda': 18,
141141
'min_child_weight': 16,
142-
'tree_method': 'gpu_hist',
142+
# 'tree_method': 'gpu_hist',
143143
'verbose_eval': 100
144144
}
145145
if params is not None:
@@ -165,7 +165,7 @@ def objective(trial):
165165
'reg_lambda': trial.suggest_int('reg_lambda', 5, 100),
166166
'min_child_weight': trial.suggest_int('min_child_weight', 5, 20),
167167
}
168-
reg = xgb.XGBRegressor(tree_method='gpu_hist', **param_grid)
168+
reg = xgb.XGBRegressor(**param_grid) # tree_method='gpu_hist',
169169
reg.fit(X_train, y_train,
170170
eval_set=[(X_valid, y_valid)], eval_metric=metric,
171171
verbose=False)
@@ -192,7 +192,7 @@ def objective(trial):
192192

193193
self.params_ = trial.params
194194
self.params_['eta'] = 0.01
195-
self.params_['tree_method'] = 'gpu_hist'
195+
# self.params_['tree_method'] = 'gpu_hist'
196196

197197
def fit(self, X, y, tuning=True, Debug=False, log1p=True):
198198
log(X.shape)

autox/run.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
ap = argparse.ArgumentParser(description='run_autox.py')
55
ap.add_argument('path_input', nargs=1, action="store", type=str)
6+
ap.add_argument('path_output', nargs=1, action="store", type=str)
67
pa = ap.parse_args()
78
path_input = pa.path_input[0]
9+
path_output = pa.path_output[0]
810
print("path_input: ", path_input)
11+
print("path_output: ", path_output)
912

1013

1114

@@ -18,4 +21,4 @@
1821

1922
sub = autox.get_submit()
2023

21-
sub.to_csv(f"autox_{data_name}_oneclick.csv", index = False)
24+
sub.to_csv(f"{path_output}/autox_{data_name}_oneclick.csv", index = False)

submit.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_run_sh(hdfs_env, hdfs_input, path_src, time_str, app_name, mem):
1313

1414
# python_cmd = 'python -u main.py {} {} | tee {}/log.txt'.format(path_input, path_output, path_output)
1515
# python_cmd = 'python -u fengdian_ensemble.py {} -1 {} | tee {}/log.txt'.format(path_output, path_input, path_output)
16-
python_cmd = f'python -u run.py {path_input} | tee {path_output}/kaggle_house_price.log'
16+
python_cmd = f'python -u run.py {path_input} {path_output} | tee {path_output}/kaggle_house_price.log'
1717

1818
cmd_hdfs_get = 'hdfs dfs -get {}/{}/ .'.format(hdfs_input, name_output)
1919
file = open('cmd_hdfs_get.sh', 'a')
@@ -63,7 +63,7 @@ def get_run_sh(hdfs_env, hdfs_input, path_src, time_str, app_name, mem):
6363
s += ['echo "[+] output......"']
6464
s += ['mkdir {}'.format(name_output)]
6565
s += ['hdfs dfs -put -f -p {}/ {}/'.format(name_output, hdfs_input)]
66-
s += ['hdfs dfs -put -f src.tar.gz {}/{}/'.format(hdfs_input, name_output)]
66+
s += ['hdfs dfs -put -f autox.tar.gz {}/{}/'.format(hdfs_input, name_output)]
6767
s += ['hdfs dfs -put -f run.sh {}/{}/'.format(hdfs_input, name_output)]
6868
s += ['hdfs dfs -put -f yarn.sh {}/{}/'.format(hdfs_input, name_output)]
6969
s += ['hdfs dfs -put -f submit.py {}/{}/'.format(hdfs_input, name_output)]
@@ -101,7 +101,7 @@ def get_yarn_sh(appname, mem=65536, queue='pico'):
101101
s += [' --num_containers=1 \\']
102102
s += [' --shell_env HADOOP_USER_NAME=`whoami`\\']
103103
s += [' --shell_env WEBHDFS_USER=`whoami` \\']
104-
s += [' --file src.tar.gz \\']
104+
s += [' --file autox.tar.gz \\']
105105
s += [' --file submit.py \\']
106106
s += [' --file run.sh \\']
107107
s += [' --file yarn.sh']
@@ -159,7 +159,7 @@ def tar_src(path_src):
159159
return path_src
160160

161161

162-
path_src = 'src'
162+
path_src = 'autox'
163163
path_src = tar_src(path_src)
164164
if path_src is None:
165165
print('[+] src not exist!')

0 commit comments

Comments
 (0)