GrandaddyShmax / audiocraft_plus

Audiocraft is a library for audio processing and generation with deep learning. It features the state-of-the-art EnCodec audio compressor / tokenizer, along with MusicGen, a simple and controllable music generation LM with textual and melodic conditioning.
MIT License
561 stars 63 forks source link

UnboundLocalError: cannot access local variable 'sentencepiece_model_pb2' where it is not associated with a value #40

Closed Pluelagoon closed 1 year ago

Pluelagoon commented 1 year ago

i keep getting this error when trying to generate

Loading model GrandaddyShmax/musicgen-large Traceback (most recent call last): File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\routes.py", line 488, in run_predict output = await app.get_blocks().process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\blocks.py", line 1431, in process_api result = await self.call_function( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\blocks.py", line 1109, in call_function prediction = await anyio.to_thread.run_sync( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio\to_thread.py", line 28, in run_sync return await get_asynclib().run_sync_in_worker_thread(func, args, cancellable=cancellable, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio_backends_asyncio.py", line 754, in run result = context.run(func, args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\utils.py", line 706, in wrapper response = f(args, kwargs) ^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\app.py", line 857, in predict_full load_model(model, custom_model, gen_type) File "Z:\Progams\AI\audiocraft_plus\app.py", line 154, in load_model MODEL = MusicGen.get_pretrained(version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\audiocraft\models\musicgen.py", line 111, in get_pretrained lm = load_lm_model(name, device=device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\audiocraft\models\loaders.py", line 111, in load_lm_model model = builders.get_lm_model(cfg) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\audiocraft\models\builders.py", line 97, in get_lm_model condition_provider = get_conditioner_provider(kwargs["dim"], cfg).to(cfg.device) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\audiocraft\models\builders.py", line 137, in get_conditioner_provider conditioners[str(cond)] = T5Conditioner(output_dim=output_dim, device=device, model_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\audiocraft\modules\conditioners.py", line 415, in init self.t5_tokenizer = T5Tokenizer.from_pretrained(name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\transformers\tokenization_utils_base.py", line 1854, in from_pretrained return cls._from_pretrained( ^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\transformers\tokenization_utils_base.py", line 2017, in _from_pretrained tokenizer = cls(init_inputs, **init_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\transformers\models\t5\tokenization_t5.py", line 194, in init self.sp_model = self.get_spm_processor() ^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\transformers\models\t5\tokenization_t5.py", line 200, in get_spm_processor model_pb2 = import_protobuf() ^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\transformers\convert_slow_tokenizer.py", line 40, in import_protobuf return sentencepiece_model_pb2 ^^^^^^^^^^^^^^^^^^^^^^^ UnboundLocalError: cannot access local variable 'sentencepiece_model_pb2' where it is not associated with a value

GrandaddyShmax commented 1 year ago

I cannot run it locally on my pc so I cannot test it.. but my guess is that you are missing something, it does not seem to be related to any of my changes. maybe try clean install? or are installing mine on top of the original one?

Pluelagoon commented 1 year ago

should the models get downloaded here it? explorer_MjDfaMKlG5 cause it auto downloads in that cache folder.

blackwitch commented 1 year ago

See the answer of #41

Pluelagoon commented 1 year ago

solved the not generating but now it gives me a new error once it finishes generating

False OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/. Traceback (most recent call last): File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\routes.py", line 488, in run_predict output = await app.get_blocks().process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\blocks.py", line 1431, in process_api result = await self.call_function( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\blocks.py", line 1109, in call_function prediction = await anyio.to_thread.run_sync( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio\to_thread.py", line 28, in run_sync return await get_asynclib().run_sync_in_worker_thread(func, args, cancellable=cancellable, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\anyio_backends_asyncio.py", line 754, in run result = context.run(func, args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\site-packages\gradio\utils.py", line 706, in wrapper response = f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\app.py", line 914, in predict_full outs, outs_audio, outs_backup, input_length = _do_predictions( ^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\app.py", line 621, in _do_predictions res = [out_file.result() for out_file in out_files] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\AI\audiocraft_plus\app.py", line 621, in res = [out_file.result() for out_file in out_files] ^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\concurrent\futures_base.py", line 456, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "Z:\Progams\Anaconda3\Lib\concurrent\futures_base.py", line 401, in get_result raise self._exception concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

blackwitch commented 1 year ago

This can occur when different versions of the libiomp5md.dll file exist. I recommend cleaning up your installed libraries to resolve the root cause. To see if it works first, try adding the code below to the top of your app.py and running it (I can't guarantee because it doesn't reproduce on my PC).

import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
Pluelagoon commented 1 year ago

yea it works now, but how do you suppose i go about cleaning my libraries?

blackwitch commented 1 year ago

Unfortunately, I don't think I can give you detailed instructions on that. Because I don't know what paths the different versions of those dlls were installed through. I'd recommend doing a full search on the name of the DLL, looking at the path and version of the DLL installed, and figuring it out on your own. There is a simple way to reinstall the OS, but I don't think that's the answer you're looking for. Good luck!

Pluelagoon commented 1 year ago

one last question, do you know how could i move the models folder from the cache folder?

blackwitch commented 1 year ago

@Pluelagoon In the original project, there was no parameter to set the path of model files.