[tune] torchtext pickle error
See original GitHub issueThe following codes run on the colab,
analysis = tune.run(train_lstm, config={
"lr": tune.grid_search([0.0005, 0.001, 0.005]),
"clip": tune.grid_search([1.0, 0.5, 0.1])
}
)
print("Best config: ", analysis.get_best_config(metric="mean_accuracy"))
# Get a dataframe for analyzing trial results.
df = analysis.dataframe()
where train_lstm
is my own fined function using pytorch.
<ipython-input-31-c51e8c1cd47e> in <module>()
2 analysis = tune.run(train_lstm, config={
3 "lr": tune.grid_search([0.0005, 0.001, 0.005]),
----> 4 "clip": tune.grid_search([1.0, 0.5, 0.1])
5 }
6 )
5 frames
/usr/local/lib/python3.6/dist-packages/ray/tune/tune.py in run(run_or_experiment, name, stop, config, resources_per_trial, num_samples, local_dir, upload_dir, trial_name_creator, loggers, sync_to_cloud, sync_to_driver, checkpoint_freq, checkpoint_at_end, sync_on_checkpoint, keep_checkpoints_num, checkpoint_score_attr, global_checkpoint_period, export_formats, max_failures, restore, search_alg, scheduler, with_server, server_port, verbose, resume, queue_trials, reuse_actors, trial_executor, raise_on_failed_trial, return_trials, ray_auto_init, sync_function)
227 for i, exp in enumerate(experiments):
228 if not isinstance(exp, Experiment):
--> 229 run_identifier = Experiment.register_if_needed(exp)
230 experiments[i] = Experiment(
231 name=name,
/usr/local/lib/python3.6/dist-packages/ray/tune/experiment.py in register_if_needed(cls, run_object)
210 logger.warning(
211 "No name detected on trainable. Using {}.".format(name))
--> 212 register_trainable(name, run_object)
213 return name
214 else:
/usr/local/lib/python3.6/dist-packages/ray/tune/registry.py in register_trainable(name, trainable)
65 raise TypeError("Second argument must be convertable to Trainable",
66 trainable)
---> 67 _global_registry.register(TRAINABLE_CLASS, name, trainable)
68
69
/usr/local/lib/python3.6/dist-packages/ray/tune/registry.py in register(self, category, key, value)
104 raise TuneError("Unknown category {} not among {}".format(
105 category, KNOWN_CATEGORIES))
--> 106 self._to_flush[(category, key)] = pickle.dumps(value)
107 if _internal_kv_initialized():
108 self.flush_values()
/usr/local/lib/python3.6/dist-packages/ray/cloudpickle/cloudpickle_fast.py in dumps(obj, protocol, buffer_callback)
66 with io.BytesIO() as file:
67 cp = CloudPickler(file, protocol=protocol, buffer_callback=buffer_callback)
---> 68 cp.dump(obj)
69 return file.getvalue()
70
/usr/local/lib/python3.6/dist-packages/ray/cloudpickle/cloudpickle_fast.py in dump(self, obj)
555 def dump(self, obj):
556 try:
--> 557 return Pickler.dump(self, obj)
558 except RuntimeError as e:
559 if "recursion" in e.args[0]:
TypeError: 'generator' object is not callable
Can anyone figure out what is run with the pickle?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Newest 'torchtext' Questions - Stack Overflow
I am trying to use torchtext to process test data, however, I get the error: "AttributeError: module 'torchtext' has no attribute 'legacy'", when...
Read more >Language modeling - Jupyter Notebooks Gallery
First, we create a torchtext field, which describes how to preprocess a piece of text - in this case, we tell torchtext to...
Read more >Changelog — PyTorch Lightning 1.8.5 documentation
Fixed a pickling error when using RichProgressBar together with checkpointing (#15319). Fixed the RichProgressBar crashing when used with distributed ...
Read more >torchtext Changelog - pyup.io
Fix OBO error for vocab files with empty lines (1841) * Fixing build when CUDA enabled torch is ... Added parameterized dataset pickling...
Read more >A Tutorial on Torchtext - Allen Nie
import spacy spacy_en = spacy.load('en') def tokenizer(text): # create a tokenizer function return [tok.text for tok in spacy_en. · train, val, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the slow reply - I actually thought I posted a reply already 😃
This is a scoping issue. Torchtext fields and datasets need to be created within the Trainable because the Trainable needs to be pickled and replicated across multiple parallel processes.
If they are not, Ray/cloudpickle will try to serialize them and fail.
For example, you’ll want to do something like:
Thanks @richardliaw , and I will close #7202