deezer / spleeter

Deezer source separation library including pretrained models.
https://research.deezer.com/projects/spleeter.html
MIT License
25.96k stars 2.84k forks source link

GPU version finally works for me. Here are the steps... #739

Open robertmckean opened 2 years ago

robertmckean commented 2 years ago

I spent the entire weekend trying to get spleeeter to work with GPU (maybe I'm slow...). I could make combinations of versions work with the CPU, but the command line always failed with the GPU enabled. The following steps finally worked!

I don't show the steps to clone the spleeter project from github, since these files were already in place from previous attempts. Also note: I only tested the command line version of 'separate.' Since this worked, I'm going to assume (for now) that the problem is solved. At least it is running with the GPU. If I had more time, I suppose I could increase the version of cudnn and the tools until it failed. I'd be interested if someone else got it working with a more recent rev.

I have an Asus G14 Zephyrus with an NVIDIA GeForce RTX 3060 Laptop GPU and an AMD Ryzen 9 5900HS.

Here are the steps:

  1. From Anaconda Navigator, I created a new environment with Python 3.9.7 and a CMD.exe Prompt.

  2. From the new CMD Prompt, I typed the following commands:

(Python_3_9_7) C:\Users\windo>conda create -n tensorflow2.5 python=3.9 (Python_3_9_7) C:\Users\windo>conda activate tensorflow2.5 (tensorflow2.5) C:\Users\windo>conda install cudatoolkit=10.0.130 (tensorflow2.5) C:\Users\windo>conda install cudnn=7.3.1 (tensorflow2.5) C:\Users\windo>pip3 install tensorflow-gpu==2.5 (tensorflow2.5) C:\Users\windo>conda install -c conda-forge ffmpeg libsndfile (tensorflow2.5) C:\Users\windo>pip install spleeter

(tensorflow2.5) C:\Users\windo>nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2022 NVIDIA Corporation Built on Thu_Feb_10_19:03:51_Pacific_Standard_Time_2022 Cuda compilation tools, release 11.6, V11.6.112 Build cuda_11.6.r11.6/compiler.30978841_0

For reference, here is the list of of my environment, including version numbers:

(tensorflow2.5) C:\Users\windo>conda list

Packages in environment at C:\Anaconda\envs\tensorflow2.5:

Name Version Build Channel absl-py 0.15.0 pypi_0 pypi astunparse 1.6.3 pypi_0 pypi ca-certificates 2022.2.1 haa95532_0 cachetools 5.0.0 pypi_0 pypi certifi 2021.10.8 py39haa95532_2 charset-normalizer 2.0.12 pypi_0 pypi cudatoolkit 10.0.130 0 cudnn 7.3.1 cuda10.0_0 flatbuffers 1.12 pypi_0 pypi gast 0.4.0 pypi_0 pypi google-auth 2.6.0 pypi_0 pypi google-auth-oauthlib 0.4.6 pypi_0 pypi google-pasta 0.2.0 pypi_0 pypi grpcio 1.34.1 pypi_0 pypi h5py 3.1.0 pypi_0 pypi idna 3.3 pypi_0 pypi importlib-metadata 4.11.3 pypi_0 pypi keras-nightly 2.5.0.dev2021032900 pypi_0 pypi keras-preprocessing 1.1.2 pypi_0 pypi markdown 3.3.6 pypi_0 pypi numpy 1.19.5 pypi_0 pypi oauthlib 3.2.0 pypi_0 pypi openssl 1.1.1m h2bbff1b_0 opt-einsum 3.3.0 pypi_0 pypi pip 21.2.4 py39haa95532_0 protobuf 3.19.4 pypi_0 pypi pyasn1 0.4.8 pypi_0 pypi pyasn1-modules 0.2.8 pypi_0 pypi python 3.9.7 h6244533_1 requests 2.27.1 pypi_0 pypi requests-oauthlib 1.3.1 pypi_0 pypi rsa 4.8 pypi_0 pypi setuptools 58.0.4 py39haa95532_0 six 1.15.0 pypi_0 pypi sqlite 3.38.0 h2bbff1b_0 tensorboard 2.8.0 pypi_0 pypi tensorboard-data-server 0.6.1 pypi_0 pypi tensorboard-plugin-wit 1.8.1 pypi_0 pypi tensorflow-estimator 2.5.0 pypi_0 pypi tensorflow-gpu 2.5.0 pypi_0 pypi termcolor 1.1.0 pypi_0 pypi typing-extensions 3.7.4.3 pypi_0 pypi tzdata 2021e hda174b7_0 urllib3 1.26.8 pypi_0 pypi vc 14.2 h21ff451_1 vs2015_runtime 14.27.29016 h5e58377_2 werkzeug 2.0.3 pypi_0 pypi wheel 0.37.1 pyhd3eb1b0_0 wincertstore 0.2 py39haa95532_2 wrapt 1.12.1 pypi_0 pypi zipp 3.7.0 pypi_0 pypi

Hope this helps someone!

romi1502 commented 2 years ago

Hi @robertmckean, thanks for the help! Note that there are also docker images that are supposed to work with GPUs (they were tested on linux only, not windows though).

robertmckean commented 2 years ago

Thanks, Romain!

I’ll review the docker images. I haven’t used docker before – I’m a ‘weekend’ programmer. My next goal is to build the project in PyCharm so I can run and modify it. I’m already failing the command line tests, so there’s something I’m missing. I’d like to hire a Python expert to Zoom call for a couple of hours to me get the program running. If you know anyone who would be interested, please feel free to forward them to me.

Best regards,

::Robert

From: Romain Hennequin @.> Sent: Monday, March 14, 2022 1:05 AM To: deezer/spleeter @.> Cc: robertmckean @.>; Mention @.> Subject: Re: [deezer/spleeter] GPU version finally works for me. Here are the steps... (Issue #739)

Hi @robertmckean https://github.com/robertmckean , thanks for the help! Note that there are also docker images https://hub.docker.com/r/deezer/spleeter-gpu/tags that are supposed to work with GPUs (they were tested on linux only, not windows though).

— Reply to this email directly, view it on GitHub https://github.com/deezer/spleeter/issues/739#issuecomment-1066485229 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWUNIUWVKQ23G3SP4OGGDU73XMTANCNFSM5QUTQM5A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . You are receiving this because you were mentioned. https://github.com/notifications/beacon/AAFWUNIQGXKXAYTY5PWEOWDU73XMTA5CNFSM5QUTQM5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOH6IUL3I.gif Message ID: @. @.> >

deskstar90 commented 2 years ago

@robertmckean , I am not running Anaconda as I had issues with it, but if you figure out how to use Docker pls report as I'm still struggling to understand the process on Win10. BTW, Good work on your findings and thanks.

h3rmit-git commented 1 year ago

I just managed to run the latest Spleeter v2.3.1 on GPU in Windows 7, on my GTX 1050 Ti (4GB) card. The process was far simpler and didn't require Anaconda, thanks to SpleeterGUI. I'll share it here in case it helps anyone:

SpleeterGUI includes:

The chosen CUDA and cuDNN versions were based on this discussion about Tensorflow 2.5.0: https://discuss.tensorflow.org/t/tensorflow-2-5-with-gpu-device-python-3-9-cuda-11-2-2-cudnn-8-1-1-conda-environment-windows-10/1385

It worked perfectly for 2stems and 4stems. The 5stems model threw an "out of memory" error in TensorFlow (it probably needed more than 4GB of VRAM in the GPU).

Hope it helps!

deskstar90 commented 1 year ago

@h3rmit-git Hey, thank you so much. I've been off Spleeter for a while now since many failed weekend attempts, but I will try it again this coming weekend Will this procedure work on W10 as well?

deskstar90 commented 1 year ago

@h3rmit-git I just realized that you have your own GUI which is only for splitting, and that my last attempts were to train models using GPU as it was taking an eternity to complete with CPU/RAM only. I had no issues separating using CLI. but this gives an idea of what I need, just have to figure out how to put it all together and run from CLI. The unknown is to know which of the many firmware versions will be compatible with my Hardware. thanks for the help.

workprintstudios commented 10 months ago

100% best guide on the internet.

Generating 5stem splits in 1 minute or less on 6gb Nvidia1060ti for 4 second song. Make sure you're activate the conda environment when specified. The (Python_3_9_7) and (tensorflow2.5) in the breakdown list specify which environment to run the command in.

IT HAS TO BE PYTHON 3.9.7

OhBobb commented 9 months ago

100% best guide on the internet.

Generating 5stem splits in 1 minute or less on 6gb Nvidia1060ti for 4 second song. Make sure you're activate the conda environment when specified. The (Python_3_9_7) and (tensorflow2.5) in the breakdown list specify which environment to run the command in.

IT HAS TO BE PYTHON 3.9.7

@workprintstudios can you please elaborate in more detail. I have the same output as the issue here: https://github.com/deezer/spleeter/issues/775

I followed the steps as @robertmckean showed here

This is the command I run: spleeter separate -o D:\location\to\save\output\ D:\location\of\audio\file.wav --verbose

When I check gpu usage it stays at 0 but cpu and RAM spike during the process. And I should mention that the audio file is 5hr long but the output only does 10mins of it(maybe a separate issue here but first want to solve the gpu issue first)

OhBobb commented 9 months ago

After a few days of working on this I think I finally got it working. These are the steps I did(pretty much the same as OP here but a bit different)(and I'm no expert but pretty certain some could be ran in different order, your mileage will vary i guess):

Open miniconda cmd window Create a new env named "spleeter"(or whatever you want to name your new env) and python 3.9 with this command: (base) c:\windows\system32> conda create -n spleeter python=3.9

Activate the "spleeter" env with this command: (base) c:\windows\system32>conda activate spleeter

Install tensorflow(no specific version specified)(the newer version of spleeter should be compatible and/or will install the correct dependencies) with this command: (spleeter) c:\windows\system32>pip install tensorflow

Install cudatoolkit(no specific version specified) with this command: (spleeter) c:\windows\system32>conda install cudatoolkit

Install 'cudnn'(no specific version specified) with this command: (spleeter) c:\windows\system32>conda install cudnn

Install ffmpeg/libsndfile(not totally sure if this is necessary as spleeter may automatically install but not completely sure) with this command: (spleeter) c:\windows\system32>conda install -c conda-forge ffmpeg libsndfile

Install spleeter with this command: (spleeter) c:\windows\system32>pip install spleeter **note:You may get either an error or warning of certain dependencies related to tensorflow after running pip install spleeter but I ignored them.

I then got an error when running a spleeter separate command regarding "Could not locate zlibwapi.dll. Please make sure it is in your library path". I followed this link to download the dll: https://forums.developer.nvidia.com/t/could-not-load-library-cudnn-cnn-infer64-8-dll-error-code-193/218437/16 but I did not place the file in the nvidia folder. I instead placed the file in both "c:\windows\system32\" and "c:\windows\syswow64\" and the error went away. I also used the 64bit version of the file. Not sure if its a bad idea to have placed the file in those folders but for now I am going to leave there.

Running spleeter My test file is ~5hrs long and I'm getting OOM(out of memory) errors when running the command with the -d parameter. I tested to about 2400(seconds) and then fails and throws OOM errors. I guess there is a limitation and for longer duration the process has to be split. Of course, it could be an issue with my setup as well: -i3 -16GB RAM -RTX 3090 -Windows 10 Pro For training it might also be an issue but havent gone that far yet in my journey. I am planning to at least up the RAM to 32gb soon.

Hope this helps someone.