Running keras-tuner with tf-nightly-gpu-2.0-preview 2.0.0.dev20190718 on Windows 10 through a Jupyter server. RandomSearch fails with error code [WinError21]. This is the traceback:
`PermissionError Traceback (most recent call last)
in
4 batch_size=32,
5 callbacks=[rlr_callback, earlystop_callback],
----> 6 validation_data=(transformed_test[0], transformed_test[1]))
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\engine\tuner.py in search(self, *fit_args, **fit_kwargs)
219 self.trials.append(trial)
220 self.on_trial_begin(trial)
--> 221 self.run_trial(trial, hp, fit_args, fit_kwargs)
222 self.on_trial_end(trial)
223 self.on_search_end()
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\engine\tuner.py in run_trial(self, trial, hp, fit_args, fit_kwargs)
257 fit_kwargs['callbacks'] = self._inject_callbacks(
258 original_callbacks, trial, execution)
--> 259 model.fit(*fit_args, **fit_kwargs)
260 self.on_execution_end(trial, execution, model)
261
~\Anaconda3\envs\jupyter-server\lib\site-packages\tensorflow_core\python\keras\engine\training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
698 max_queue_size=max_queue_size,
699 workers=workers,
--> 700 use_multiprocessing=use_multiprocessing)
701
702 def evaluate(self,
~\Anaconda3\envs\jupyter-server\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs)
667 validation_steps=validation_steps,
668 validation_freq=validation_freq,
--> 669 steps_name='steps_per_epoch')
670
671 def evaluate(self,
~\Anaconda3\envs\jupyter-server\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py in model_iteration(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq, mode, validation_in_fit, prepared_feed_values_from_dataset, steps_name, **kwargs)
397 # Callbacks batch end.
398 batch_logs = cbks.make_logs(model, batch_logs, batch_outs, mode)
--> 399 callbacks._call_batch_hook(mode, 'end', batch_index, batch_logs)
400 progbar.on_batch_end(batch_index, batch_logs)
401
~\Anaconda3\envs\jupyter-server\lib\site-packages\tensorflow_core\python\keras\callbacks.py in _call_batch_hook(self, mode, hook, batch, logs)
231 for callback in self.callbacks:
232 batch_hook = getattr(callback, hook_name)
--> 233 batch_hook(batch, logs)
234 self._delta_ts[hook_name].append(time.time() - t_before_callbacks)
235
~\Anaconda3\envs\jupyter-server\lib\site-packages\tensorflow_core\python\keras\callbacks.py in on_train_batch_end(self, batch, logs)
514 """
515 # For backwards compatibility.
--> 516 self.on_batch_end(batch, logs=logs)
517
518 def on_test_batch_begin(self, batch, logs=None):
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\engine\tuner_utils.py in on_batch_end(self, batch, logs)
89
90 def on_batch_end(self, batch, logs=None):
---> 91 self.tuner.on_batch_end(self.execution, self.model, batch, logs)
92
93 def on_epoch_end(self, epoch, logs=None):
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\engine\tuner.py in on_batch_end(self, execution, model, batch, logs)
284 execution.per_batch_metrics.update(name, float(value))
285 self._checkpoint_execution(execution)
--> 286 self._display.on_batch_end(execution, model, batch, logs=logs)
287
288 def on_epoch_end(self, execution, model, epoch, logs=None):
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\engine\tuner_utils.py in on_batch_end(self, execution, model, batch, logs)
182 # create bar desc with updated statistics
183 description = ''
--> 184 host_status = self.host.get_status()
185 if len(host_status['gpu']):
186 gpu_usage = [float(gpu['usage']) for gpu in host_status['gpu']]
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\abstractions\host.py in get_status(self, no_cach)
92 status['gpu'] = self._get_gpu_usage()
93 status['uptime'] = self._get_uptime()
---> 94 status['disk'] = self._get_disk_usage()
95 status['software'] = self.software
96 status['hostname'] = self.hostname
~\Anaconda3\envs\jupyter-server\lib\site-packages\kerastuner\abstractions\host.py in _get_disk_usage(self)
190 for partition in self.partitions:
191 name = partition.mountpoint
--> 192 usage = psutil.disk_usage(name)
193 info = {
194 "name": name,
~\Anaconda3\envs\jupyter-server\lib\site-packages\psutil\__init__.py in disk_usage(path)
2119 plus the percentage usage.
2120 """
-> 2121 return _psplatform.disk_usage(path)
2122
2123
~\Anaconda3\envs\jupyter-server\lib\site-packages\psutil\_pswindows.py in disk_usage(path)
291 # to fail immediately. After all we are accepting input here...
292 path = path.decode(ENCODING, errors="strict")
--> 293 total, free = cext.disk_usage(path)
294 used = total - free
295 percent = usage_percent(used, total, round_=1)
PermissionError: [WinError 21] Le périphérique n’est pas prêt: 'E'`
On my machine, 'E' is the CD drive.
This seems related to asking for disk usage through psutil for all drives indiscriminately. The error can be reproduced with the following on a machine with a cd drive:
I propose a fix which is to ignore removable drives when getting disk usage statistics:
if partition.opts.upper() in ('CDROM', 'REMOVABLE'):
continue