Fix torch issue (by @GeekyGhost)

pull/29/head
artificial 2023-05-29 14:59:15 -07:00
parent 743034d33b
commit a9b48c6e5a
No known key found for this signature in database
GPG Key ID: B7265D4DDEDDCD3D
1 changed files with 15 additions and 21 deletions

View File

@ -3,6 +3,7 @@ import sys
import platform
import torch
import launch
import pkg_resources
req_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "requirements.txt")
@ -11,29 +12,22 @@ riffusion_skip_install = os.environ.get("RIFFUSION_SKIP_INSTALL", False)
if not riffusion_skip_install:
name = "Riffusion"
if not launch.is_installed("torchaudio"):
if platform.system() == "Darwin" or launch.is_installed("torch_directml"):
# MacOS and DirectML
launch.run(
f'"{sys.executable}" -m pip install torchaudio==0.13.1',
f"[{name}] Installing torchaudio...",
f"[{name}] Couldn't install torchaudio.",
)
elif torch.version.hip:
launch.run(
f'"{sys.executable}" -m pip install torchaudio==0.13.1+rocm5.2 --extra-index-url https://download.pytorch.org/whl/rocm5.2',
f"[{name}] Installing torchaudio...",
f"[{name}] Couldn't install torchaudio.",
)
else:
launch.run(
f'"{sys.executable}" -m pip install torchaudio==0.13.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117',
f"[{name}] Installing torchaudio...",
f"[{name}] Couldn't install torchaudio.",
)
# Check if torchaudio is already installed
try:
dist = pkg_resources.get_distribution('torchaudio')
print(f"{name} torchaudio version: {dist.version} is already installed.")
except pkg_resources.DistributionNotFound:
print(f"{name} torchaudio is not installed, installing...")
launch.run(
f'"{sys.executable}" -m pip install torchaudio',
f"[{name}] Installing torchaudio...",
f"[{name}] Couldn't install torchaudio.",
)
# Install other requirements
launch.run(
f'"{sys.executable}" -m pip install -r "{req_file}"',
f"[{name}] Installing requirements...",
f"[{name}] Couldn't install requirements.",
)
)