mirror of
https://github.com/vladmandic/automatic
synced 2026-08-31 17:41:06 +02:00
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
import os
|
|
import sys
|
|
|
|
ver = '1.0.1.dev20240109'
|
|
torch_supported = ['211', '212']
|
|
cuda_supported = ['cu118', 'cu121']
|
|
python_supported = ['39', '310', '311']
|
|
repo_url = 'https://github.com/chengzeyi/stable-fast'
|
|
path_url = '/releases/download/nightly'
|
|
|
|
|
|
def install_pip(arg: str):
|
|
import subprocess
|
|
cmd = f'"{sys.executable}" -m pip install -U {arg}'
|
|
print(f'Running: {cmd}')
|
|
result = subprocess.run(cmd, shell=True, check=False, env=os.environ)
|
|
return result.returncode == 0
|
|
|
|
|
|
def install_stable_fast():
|
|
import torch
|
|
|
|
python_ver = f'{sys.version_info.major}{sys.version_info.minor}'
|
|
if python_ver not in python_supported:
|
|
raise ValueError(f'StableFast unsupported python: {python_ver} required {python_supported}')
|
|
if sys.platform == 'linux':
|
|
bin_url = 'manylinux2014_x86_64.whl'
|
|
elif sys.platform == 'win32':
|
|
bin_url = 'win_amd64.whl'
|
|
else:
|
|
raise ValueError(f'StableFast unsupported platform: {sys.platform}')
|
|
|
|
torch_ver, cuda_ver = torch.__version__.split('+')
|
|
torch_ver = torch_ver.replace('.', '')
|
|
|
|
if torch_ver not in torch_supported:
|
|
print(f'StableFast unsupported torch: {torch_ver} required {torch_supported}')
|
|
print('Installing from source...')
|
|
url = 'git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast'
|
|
elif cuda_ver not in cuda_supported:
|
|
print(f'StableFast unsupported CUDA: {cuda_ver} required {cuda_supported}')
|
|
print('Installing from source...')
|
|
url = 'git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast'
|
|
else:
|
|
print('Installing wheel...')
|
|
file_url = f'stable_fast-{ver}+torch{torch_ver}{cuda_ver}-cp{python_ver}-cp{python_ver}-{bin_url}'
|
|
url = f'{repo_url}/{path_url}/{file_url}'
|
|
|
|
ok = install_pip(url)
|
|
if ok:
|
|
import sfast
|
|
print(f'StableFast installed: {sfast.__version__}')
|
|
else:
|
|
print('StableFast install failed')
|
|
|
|
if __name__ == '__main__':
|
|
install_stable_fast()
|