upgraded modules

This commit is contained in:
Saifeddine ALOUI 2024-02-28 01:06:52 +01:00
parent 1e0e91ed94
commit f7bc693b35
5 changed files with 86 additions and 39 deletions

View File

@ -0,0 +1,26 @@
#!/bin/bash
# Check if miniconda3/bin/conda exists
if [ -e "$HOME/miniconda3/bin/conda" ]; then
echo "Conda is installed!"
else
echo "Conda is not installed. Please install it first."
echo Installing conda
curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b
rm ./Miniconda3-latest-Linux-x86_64.sh
echo Done
fi
PATH="$HOME/miniconda3/bin:$PATH"
export PATH
echo "Initializing conda"
conda init --all
export PATH
echo "Installing motion_ctrl"
conda create -n motion_ctrl python=3.9 -y
echo "Activating motion_ctrl environment"
source activate motion_ctrl
git clone https://github.com/ParisNeo/MotionCtrl.git
cd MotionCtrl
pip install -r requirements.txt
echo "Done"

View File

@ -30,6 +30,8 @@ from typing import List, Dict, Any
from ascii_colors import ASCIIColors, trace_exception
from lollms.paths import LollmsPaths
from lollms.utilities import git_pull
from lollms.utilities import url2host_port
import subprocess
import shutil
@ -44,37 +46,30 @@ def verify_motion_ctrl(lollms_paths:LollmsPaths):
return motion_ctrl_folder.exists()
def install_motion_ctrl(lollms_app:LollmsApplication):
import conda.cli
if platform.system() == 'Windows':
root_path = "/mnt/"+"".join(str(Path(__file__).parent).replace("\\","/").split(":"))
if not os.path.exists('C:\\Windows\\System32\\wsl.exe'):
if not show_yes_no_dialog("No WSL is detected on your system. Do you want me to install it for you? vLLM won't be abble to work without wsl."):
return False
subprocess.run(['wsl', '--install', 'Ubuntu'])
subprocess.run(['wsl', 'bash', '-c', 'mkdir ~/motion_ctrl'])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~/motion_ctrl'.format( root_path + '/install_motion_ctrl.sh')])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~/motion_ctrl'.format( root_path + '/run_motion_ctrl.sh')])
subprocess.run(['wsl', 'bash', '~/motion_ctrl/install_motion_ctrl.sh'])
else:
root_path = str(Path(__file__).parent)
vllm_installer_path = root_path/'install_motion_ctrl.sh'
vllm_run_path = root_path/'run_motion_ctrl.sh'
vllm_path = Path.home()/"motion_ctrl"
subprocess.run([f'mkdir {vllm_path}'])
subprocess.run([f'cp {vllm_installer_path} {vllm_path}'])
subprocess.run([f'cp {vllm_run_path} {vllm_path}'])
subprocess.run(['bash', f'{vllm_path}/install_motion_ctrl.sh'])
root_dir = lollms_app.lollms_paths.personal_path
shared_folder = root_dir/"shared"
motion_ctrl_folder = shared_folder / "auto_motion_ctrl"
if motion_ctrl_folder.exists():
if not show_yes_no_dialog("warning!","I have detected that there is a previous installation of motion ctrl.\nShould I remove it and continue installing?"):
return
else:
try:
shutil.rmtree(motion_ctrl_folder)
except Exception as ex:
trace_exception(ex)
try:
conda.cli.main('conda', 'remove', '--name', env_name, '--all', '--yes')
except Exception as ex:
trace_exception(ex)
subprocess.run(["git", "clone", "https://github.com/ParisNeo/MotionCtrl.git", str(motion_ctrl_folder)])
env_name = "MotionCtrl"
conda.cli.main('conda', 'create', '--name', env_name, 'python=3.10', '--yes')
# Replace 'your_env_name' with the name of the environment you created
activate_env_command = f"conda activate {env_name} && "
pip_install_command = "pip install -r " + str(motion_ctrl_folder) + "/requirements.txt"
# Run the combined command
subprocess.run(activate_env_command + pip_install_command, shell=True)
#pip install -r requirements.txt
ASCIIColors.green("Motion ctrl installed successfully")
vllm_folder = shared_folder / "motion_ctrl"
vllm_folder.mkdir(exist_ok=True, parents=True)
return True
def get_motion_ctrl(lollms_paths:LollmsPaths):
@ -151,10 +146,15 @@ class Service:
env_name = "MotionCtrl"
# Replace 'your_env_name' with the name of the environment you created
activate_env_command = f"conda activate {env_name} && "
pip_install_command = "python -m app --share"
pip_install_command = ""
_, host, port = url2host_port(base_url)
# run motion_ctrl
if platform.system() == 'Windows':
#subprocess.Popen(['wsl', 'ls', '$HOME'])
subprocess.Popen(['wsl', 'bash', '$HOME/run_motion_ctrl.sh', host, str(port)])
else:
subprocess.Popen(['bash', f'{Path.home()}/run_motion_ctrl.sh', host, str(port)])
# Run the combined command
subprocess.run(activate_env_command + pip_install_command, shell=True)
# Wait until the service is available at http://127.0.0.1:7860/

View File

@ -0,0 +1,14 @@
#!/bin/bash
PATH="$HOME/miniconda3/bin:$PATH"
export PATH
echo "Initializing conda"
$HOME/miniconda3/bin/conda init --all
echo "Initializing vllm with:"
echo "host :$1"
echo "port :$2"
cd MotionCtrl
source activate motion_ctrl && python -m app --share
# Wait for all background processes to finish
wait

View File

@ -51,15 +51,19 @@ def install_vllm(lollms_app:LollmsApplication):
if not show_yes_no_dialog("No WSL is detected on your system. Do you want me to install it for you? vLLM won't be abble to work without wsl."):
return False
subprocess.run(['wsl', '--install', 'Ubuntu'])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~'.format( root_path + '/install_vllm.sh')])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~'.format( root_path + '/run_vllm.sh')])
subprocess.run(['wsl', 'bash', '~/install_vllm.sh'])
subprocess.run(['wsl', 'bash', '-c', 'mkdir ~/vllm'])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~/vllm'.format( root_path + '/install_vllm.sh')])
subprocess.run(['wsl', 'bash', '-c', 'cp {} ~/vllm'.format( root_path + '/run_vllm.sh')])
subprocess.run(['wsl', 'bash', '~/vllm/install_vllm.sh'])
else:
root_path = str(Path(__file__).parent)
home = Path.home()
subprocess.run(['cp {} {}'.format( root_path + '/install_vllm.sh', home)])
subprocess.run(['cp {} {}'.format( root_path + '/run_vllm.sh', home)])
subprocess.run(['bash', f'{home}/install_vllm.sh'])
vllm_installer_path = root_path/'install_vllm.sh'
vllm_run_path = root_path/'run_vllm.sh'
vllm_path = Path.home()/"vllm"
subprocess.run([f'mkdir {vllm_path}'])
subprocess.run([f'cp {vllm_installer_path} {vllm_path}'])
subprocess.run([f'cp {vllm_run_path} {vllm_path}'])
subprocess.run(['bash', f'{vllm_path}/install_vllm.sh'])
root_dir = lollms_app.lollms_paths.personal_path
shared_folder = root_dir/"shared"
vllm_folder = shared_folder / "vllm"

View File

@ -34,6 +34,9 @@ import urllib
import os
import sys
def discussion_path_2_url(path:str|Path):
path = str(path)
return path[path.index('discussion_databases'):].replace('discussion_databases','discussions')
def get_conda_path():
# Get the path to the Python executable that's running the script