diff --git a/README.md b/README.md index ca6b26b0..6323ec04 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ https://rsxdalv.github.io/bark-speaker-directory/ https://github.com/rsxdalv/tts-generation-webui/discussions/186#discussioncomment-7291274 ## Changelog +Jan 21: +* Add CPU/M1 torch auto-repair script with each update. To disable, edit check_cuda.py and change FORCE_NO_REPAIR = True + Jan 16: * Upgrade MusicGen, adding support for stereo and large melody models * Add MAGNeT @@ -394,6 +397,21 @@ Most notably: - AudioGen: CC BY-NC 4.0 +## Compatibility / Errors + +Audiocraft is currently only compatible with Linux and Windows. MacOS support still has not arrived, although it might be possible to install manually. + +### Torch being reinstalled + +Due to the python package manager (pip) limitations, torch can get reinstalled several times. This is a wide ranging issue of pip and torch. + +### Red messages in console +These messages: +``` +---- requires ----, but you have ---- which is incompatible. +``` +Are completely normal. It's both a limitation of pip and because this Web UI combines a lot of different AI projects together. Since the projects are not always compatible with each other, they will complain about the other projects being installed. This is normal and expected. And in the end, despite the warnings/errors the projects will work together. +It's not clear if this situation will ever be resolvable, but that is the hope. ## Configuration Guide diff --git a/check_cuda.py b/check_cuda.py new file mode 100644 index 00000000..8799fcb9 --- /dev/null +++ b/check_cuda.py @@ -0,0 +1,23 @@ +import torch + +# Set this to "True" to force no repair +FORCE_NO_REPAIR = False + + +def check_if_torch_has_cuda(): + """Check if torch has CUDA available""" + if FORCE_NO_REPAIR: + print("Forcing no torch repair") + return True + try: + if torch.cuda.is_available(): + return True + else: + raise Exception("") + except Exception as e: + print("Torch does not have CUDA") + print(e) + exit(1) # set return code to 1 + + +check_if_torch_has_cuda() diff --git a/update.py b/update.py index 73a8733a..f4b1e280 100644 --- a/update.py +++ b/update.py @@ -7,7 +7,14 @@ def do(cmd): # https://stackoverflow.com/a/62986640 run.check_returncode() return run except subprocess.CalledProcessError as e: - print(e.stderr.decode().strip()) + try: + print( + e.stderr.decode().strip(), + e.returncode, + ) + except Exception: + print(e) + pass raise e @@ -42,9 +49,20 @@ def setup_node_modules(): print("Failed to install node_modules") +def check_if_torch_has_cuda(): + try: + print("Checking if torch has CUDA...") + do("python check_cuda.py") + return True + except Exception: + return False + + def main(): print("Updating dependencies...") - try_install("requirements_audiocraft_only.txt --no-deps", "musicgen, audiocraft 1/2") + try_install( + "requirements_audiocraft_only.txt --no-deps", "musicgen, audiocraft 1/2" + ) try_install("requirements_audiocraft_deps.txt", "musicgen, audiocraft 2/2") try_install( "requirements_bark_hubert_quantizer.txt", @@ -57,6 +75,16 @@ def main(): if is_node_installed(): setup_node_modules() + if check_if_torch_has_cuda(): + print("Torch has CUDA, skipping reinstall") + else: + print( + "Torch does not have CUDA, assuming CPU mode, installing CPU version of PyTorch" + ) + do( + "conda install --force-reinstall -y -k pytorch torchvision torchaudio cpuonly git -c pytorch" + ) + if __name__ == "__main__": main()