audiocraft icon indicating copy to clipboard operation
audiocraft copied to clipboard

[windows] AssertionError: Torch not compiled with CUDA enabled

Open DuckersMcQuack opened this issue 2 years ago • 12 comments

Windows 11 home 5900x, RTX 3090

Here's the full error. Installed everything from the requirements.

To create a public link, set share=True in launch(). Loading model large Traceback (most recent call last): File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\gradio\routes.py", line 437, in run_predict output = await app.get_blocks().process_api( File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\gradio\blocks.py", line 1346, in process_api result = await self.call_function( File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\gradio\blocks.py", line 1074, in call_function prediction = await anyio.to_thread.run_sync( File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\anyio_backends_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\stableaudio\audiocraft-main\app.py", line 26, in predict MODEL = load_model(model) File "C:\stableaudio\audiocraft-main\app.py", line 19, in load_model return MusicGen.get_pretrained(version) File "C:\stableaudio\audiocraft-main\audiocraft\models\musicgen.py", line 89, in get_pretrained compression_model = load_compression_model(name, device=device, cache_dir=cache_dir) File "C:\stableaudio\audiocraft-main\audiocraft\models\loaders.py", line 72, in load_compression_model model = builders.get_compression_model(cfg) File "C:\stableaudio\audiocraft-main\audiocraft\models\builders.py", line 81, in get_compression_model return EncodecModel(encoder, decoder, quantizer, File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 1145, in to return self._apply(convert) File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 797, in _apply module._apply(fn) [Previous line repeated 2 more times] File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 820, in apply param_applied = fn(param) File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\nn\modules\module.py", line 1143, in convert return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) File "C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\torch\cuda_init.py", line 239, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

DuckersMcQuack avatar Jun 12 '23 02:06 DuckersMcQuack

conda uninstall pytorch
pip uninstall torch

REBOOT, and then again, it's better to be sure

pip uninstall torch

then pick your version

conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia

or

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

JonathanFly avatar Jun 12 '23 02:06 JonathanFly

#54 try this,a one-click installation version, no need to manually enter any commands.

sdbds avatar Jun 12 '23 03:06 sdbds

You might also need ffmpeg:

conda install -y -c pytorch ffmpeg

(You can check any additional setup commands here: https://github.com/rsxdalv/one-click-installers-tts/blob/main/webui.py#L7)

rsxdalv avatar Jun 12 '23 13:06 rsxdalv

Installed ffmpeg, still the same issues.

And for the setup commands, which in particular do i need? Still kinda green on this python stuff :P

DuckersMcQuack avatar Jun 12 '23 14:06 DuckersMcQuack

In that case, if you have 10-20 gigabytes to spare, I would recommend trying a one click installer. You can try the other person's link or mine. The setup commands are a part of one click installer.

On Mon, Jun 12, 2023, 5:55 PM DuckersMcQuack @.***> wrote:

Installed ffmpeg, still the same issues.

And for the setup commands, which in particular do i need? Still kinda green on this python stuff :P

— Reply to this email directly, view it on GitHub https://github.com/facebookresearch/audiocraft/issues/68#issuecomment-1587510898, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTRXI5RLKH7N2SHOXKGNXTXK4UVHANCNFSM6AAAAAAZCW3EUA . You are receiving this because you commented.Message ID: @.***>

rsxdalv avatar Jun 12 '23 15:06 rsxdalv

Had it to work by simply running these two:

pip3 uninstall torch torchvision torchaudio
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Nothing else required.

Veylkh avatar Jun 12 '23 17:06 Veylkh

#54 try this,a one-click installation version, no need to manually enter any commands.

I will try one of those as well :)

Ran it again with anaconda navigator and got this:

(Audiocraft) C:\stableaudio\audiocraft-main>python app.py WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for: PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu) Python 3.9.13 (you have 3.9.16) Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers) Memory-efficient attention, SwiGLU, sparse and more won't be available. Set XFORMERS_MORE_DETAILS=1 for more details

then did what veylkh recommended, now it generated! :D

But i still get this issue after it downloaded a few models. Is this normal?

C:\Users\Duckers\anaconda3\envs\Audiocraft\lib\site-packages\gradio\processing_utils.py:171: UserWarning: Trying to convert audio automatically from float32 to 16-bit int format. warnings.warn(warning.format(data.dtype))

DuckersMcQuack avatar Jun 12 '23 18:06 DuckersMcQuack

it is bug see these #57 #32 ignore it now...

sdbds avatar Jun 12 '23 18:06 sdbds

#54 try this,a one-click installation version, no need to manually enter any commands.

That one worked like a treat! Thanks! :D

But for another question, if i wanna have melody and large at the same time, how would i add those? As they are both named the same.

DuckersMcQuack avatar Jun 12 '23 19:06 DuckersMcQuack

Afaik there's no public large model that also has melody enabled.

As for this: UserWarning: Trying to convert audio automatically from float32 to 16-bit int format. It doesn't matter. (Gradio complains that it has to automatically convert it, but does it anyway...)

rsxdalv avatar Jun 12 '23 19:06 rsxdalv

Had it to work by simply running these two:

pip3 uninstall torch torchvision torchaudio
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

Nothing else required.

Yup that's the key -- must install torch with cuda prior to everything else, then you're fine with the main repo setup. I've documented this here along with the very minimal stuff needed to setup the environment for those starting more from scratch. My approach should be roughly identical to the guy with the video and the guys with the one-click installers. I just liked to explain the parts in writing as my contribution. HTH

halr9000 avatar Jun 17 '23 22:06 halr9000

REBOOT, and then again, it's better to be sure

noooo every time you needlessly reboot, a puppy dies! 😆

Seriously, best is to learn how to use virtualenv or conda, and about environment variables. With that you understand:

  1. venv/conda keeps everything tidy with all dependencies in one place, preventing shared stuff from causing hard to troubleshoot issues
  2. Python has some environment variables it uses, plus the path variable can cause you to load something you didn't intend, like the wrong python version.
  3. Python came from a Linux/Unix/cross-platform land. It doesn't use or give a crap about the more Windows-centric reasons that cause reboots to be needed, like registry settings. Simply opening a new terminal window is often sufficient to clear out any env vars that might've changed, but that's not often needed either. (But it can clear out memory leaks which are even harder to troubleshoot, so puppies do not suffer when you close a terminal!)

HTH

halr9000 avatar Jun 17 '23 22:06 halr9000

conda uninstall pytorch
pip uninstall torch

REBOOT, and then again, it's better to be sure

pip uninstall torch

then pick your version

Unistalling the existing torch worked for me! Thank you.

jarryidle avatar Jul 14 '23 16:07 jarryidle