Skip to content

Python 3.9: training with CPU fails with double invocation, and no progress #35

@ronaldtse

Description

@ronaldtse

Works with Python 3.7 but not 3.9. It launches with double invocation, and no progress:

me:~/src/interscript/rababa/python (main *): python3.9 train.py --model "cbhg" --config config/cbhg.yml

CONFIGURATION CA_MSA.base.cbhg
- session_name : base
- data_directory : data
- data_type : CA_MSA
- log_directory : log_dir
- load_training_data : True
- load_test_data : False
- load_validation_data : True
- n_training_examples : None
- n_test_examples : None
- n_validation_examples : None
- test_file_name : test.csv
- is_data_preprocessed : False
- data_separator : |
- diacritics_separator : *
- text_encoder : ArabicEncoderWithStartSymbol
- text_cleaner : valid_arabic_cleaners
- max_len : 600
- reconcile : True
- max_steps : 2000000
- learning_rate : 0.001
- batch_size : 32
- adam_beta1 : 0.9
- adam_beta2 : 0.999
- use_decay : True
- weight_decay : 0.0
- embedding_dim : 256
- use_prenet : False
- prenet_sizes : [512, 256]
- cbhg_projections : [128, 256]
- cbhg_filters : 16
- cbhg_gru_units : 256
- post_cbhg_layers_units : [256, 256]
- post_cbhg_use_batch_norm : True
- use_mixed_precision : False
- optimizer_type : Adam
- device : cuda
- evaluate_frequency : 5000
- evaluate_with_error_rates_frequency : 5000
- n_predicted_text_tensorboard : 10
- model_save_frequency : 5000
- train_plotting_frequency : 50000000
- n_steps_avg_losses : [100, 500, 1000, 5000]
- error_rates_n_batches : 10000
- test_model_path : None
- train_resume_model_path : None
- len_input_symbols : 44
- len_target_symbols : 17
- optimizer : OptimizerType.Adam
- git_hash : v0.1.0-34-g4e8ffa9
The model has 15413521 trainable parameters parameters
/usr/local/lib/python3.9/site-packages/torch/cuda/amp/grad_scaler.py:115: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.")
Length of training iterator = 86962
Length of valid iterator = 4676
data loaded
----------------------------------------------------------
Eval:   0%|                                                                                                                                 | 0/4676 [00:00<?, ?it/s]
CONFIGURATION CA_MSA.base.cbhg                                                                                                              | 0/4676 [00:00<?, ?it/s]
- session_name : base                                                                                                                    | 0/2000000 [00:00<?, ?it/s]
- data_directory : data
- data_type : CA_MSA
- log_directory : log_dir
- load_training_data : True
- load_test_data : False
- load_validation_data : True
- n_training_examples : None
- n_test_examples : None
- n_validation_examples : None
- test_file_name : test.csv
- is_data_preprocessed : False
- data_separator : |
- diacritics_separator : *
- text_encoder : ArabicEncoderWithStartSymbol
- text_cleaner : valid_arabic_cleaners
- max_len : 600
- reconcile : True
- max_steps : 2000000
- learning_rate : 0.001
- batch_size : 32
- adam_beta1 : 0.9
- adam_beta2 : 0.999
- use_decay : True
- weight_decay : 0.0
- embedding_dim : 256
- use_prenet : False
- prenet_sizes : [512, 256]
- cbhg_projections : [128, 256]
- cbhg_filters : 16
- cbhg_gru_units : 256
- post_cbhg_layers_units : [256, 256]
- post_cbhg_use_batch_norm : True
- use_mixed_precision : False
- optimizer_type : Adam
- device : cuda
- evaluate_frequency : 5000
- evaluate_with_error_rates_frequency : 5000
- n_predicted_text_tensorboard : 10
- model_save_frequency : 5000
- train_plotting_frequency : 50000000
- n_steps_avg_losses : [100, 500, 1000, 5000]
- error_rates_n_batches : 10000
- test_model_path : None
- train_resume_model_path : None
- len_input_symbols : 44
- len_target_symbols : 17
- optimizer : OptimizerType.Adam
- git_hash : v0.1.0-34-g4e8ffa9
The model has 15413521 trainable parameters parameters
/usr/local/lib/python3.9/site-packages/torch/cuda/amp/grad_scaler.py:115: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.")
Length of training iterator = 86962
Length of valid iterator = 4676
data loaded
----------------------------------------------------------
Eval:   0%|                                                                                                                                 | 0/4676 [00:00<?, ?it/sTraceback (most recent call last):                                                                                                           | 0/4676 [00:00<?, ?it/s]
  File "<string>", line 1, in <module>                                                                                                   | 0/2000000 [00:00<?, ?it/s]
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/me/src/interscript/rababa/python/train.py", line 43, in <module>
    trainer.run()
  File "/Users/me/src/interscript/rababa/python/trainer.py", line 210, in run
    for batch_inputs in repeater(train_iterator):
  File "/Users/me/src/interscript/rababa/python/util/utils.py", line 64, in repeater
    for data in loader:
  File "/usr/local/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 359, in __iter__
    return self._get_iterator()
  File "/usr/local/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 305, in _get_iterator
    return _MultiProcessingDataLoaderIter(self)
  File "/usr/local/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 918, in __init__
    w.start()
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.
Eval:   0%|                                                                                                                                 | 0/4676 [00:00<?, ?it/s]
WER/DER : :   0%|                                                                                                                           | 0/4676 [00:00<?, ?it/s]
  0%|                                                                                                                                    | 0/2000000 [00:00<?, ?it/s]

Originally posted by @ronaldtse in #22 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions