diff --git a/dockerinstaller/mydockerinstaller.egg-info/PKG-INFO b/dockerinstaller/mydockerinstaller.egg-info/PKG-INFO deleted file mode 100644 index 2207a21e..00000000 --- a/dockerinstaller/mydockerinstaller.egg-info/PKG-INFO +++ /dev/null @@ -1,3 +0,0 @@ -Metadata-Version: 2.1 -Name: mydockerinstaller -Version: 0.1 diff --git a/dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt b/dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt deleted file mode 100644 index 4d00dcb0..00000000 --- a/dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt +++ /dev/null @@ -1,8 +0,0 @@ -setup.py -mydockerinstaller/__init__.py -mydockerinstaller/installer.py -mydockerinstaller.egg-info/PKG-INFO -mydockerinstaller.egg-info/SOURCES.txt -mydockerinstaller.egg-info/dependency_links.txt -mydockerinstaller.egg-info/entry_points.txt -mydockerinstaller.egg-info/top_level.txt diff --git a/dockerinstaller/mydockerinstaller.egg-info/dependency_links.txt b/dockerinstaller/mydockerinstaller.egg-info/dependency_links.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/dockerinstaller/mydockerinstaller.egg-info/entry_points.txt b/dockerinstaller/mydockerinstaller.egg-info/entry_points.txt deleted file mode 100644 index 888ccafe..00000000 --- a/dockerinstaller/mydockerinstaller.egg-info/entry_points.txt +++ /dev/null @@ -1,2 +0,0 @@ -[console_scripts] -mydockerinstaller = mydockerinstaller.installer:main diff --git a/dockerinstaller/mydockerinstaller.egg-info/top_level.txt b/dockerinstaller/mydockerinstaller.egg-info/top_level.txt deleted file mode 100644 index 473b721f..00000000 --- a/dockerinstaller/mydockerinstaller.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -mydockerinstaller diff --git a/dockerinstaller/mydockerinstaller/__init__.py b/dockerinstaller/mydockerinstaller/__init__.py deleted file mode 100644 index cd343d7c..00000000 --- a/dockerinstaller/mydockerinstaller/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from installer import run_docker_container, DockerThread diff --git a/dockerinstaller/mydockerinstaller/installer.py b/dockerinstaller/mydockerinstaller/installer.py deleted file mode 100644 index 654fd9f1..00000000 --- a/dockerinstaller/mydockerinstaller/installer.py +++ /dev/null @@ -1,231 +0,0 @@ -import subprocess -import os -import sys - - -def install_docker(): - try: - # Check if Docker is installed - subprocess.run(["docker", "--version"], check=True) - except subprocess.CalledProcessError: - # Determine the OS and install Docker - if os.name == "posix": - plat = sys.platform - if plat.startswith("linux"): - subprocess.run(["sudo", "apt-get", "update"], check=True) - subprocess.run( - ["sudo", "apt-get", "install", "-y", "docker.io"], check=True - ) - elif plat == "darwin": - subprocess.run(["brew", "install", "--cask", "docker"], check=True) - else: - sys.exit("Unsupported OS for Linux-like environments: {}".format(plat)) - elif os.name == "nt": - subprocess.run(["choco", "install", "docker-desktop"], check=True) - else: - sys.exit("Unsupported OS: {}".format(os.name)) - - -def install_nvidia_toolkit(): - if sys.platform.startswith("linux"): - subprocess.run(["sudo", "apt-get", "update"], check=True) - subprocess.run( - ["sudo", "apt-get", "install", "-y", "nvidia-container-toolkit"], check=True - ) - else: - print("NVIDIA Container Toolkit is not supported on this OS.") - - -def run_docker_container(model, volume, detach=False): - subprocess.run( - [ - "docker", - "run", - # conditionally add the -d flag to run the container in the background - # *(["-d"] if detach else []), - "-it", - "--gpus", - "all", - "--shm-size", - "1g", - "-p", - "8080:80", - "-v", - "{}:/data".format(volume), - "ghcr.io/huggingface/text-generation-inference:latest", - "--model-id", - model, - ], - check=True, - ) - - -def run_detached_docker_container(model, volume): - subprocess.run( - [ - "docker", - "run", - "-d", - "-it", - "--gpus", - "all", - "--shm-size", - "1g", - "-p", - "8080:80", - "-v", - "{}:/data".format(volume), - "ghcr.io/huggingface/text-generation-inference:latest", - "--model-id", - model, - ], - check=True, - ) - - -def main(): - print("Installing Docker...") - install_docker() - install_nvidia_toolkit() - run_docker_container("HuggingFaceH4/zephyr-7b-beta", os.getcwd() + "/data") - - -from threading import Thread -import threading - - -# a class that keeps the container running in a separate thread -class DockerThread(threading.Thread): - def __init__(self, model, volume): - threading.Thread.__init__(self) - self.model = model - self.volume = volume - - def run(self): - self._stop = threading.Event() - run_detached_docker_container(self.model, self.volume) - - def stop(self): - self._stop.set() - - -# how to use the DockerThread class -# import os - -# docker_thread = DockerThread("HuggingFaceH4/zephyr-7b-beta", os.getcwd() + "/data") - -# docker_thread.start() - -# do some other stuff - - -# import subprocess -# import os -# import sys - - -# def check_command_exists(command): -# """Check if a command exists in the system's PATH.""" -# return subprocess.run(["which", command], stdout=subprocess.PIPE).returncode == 0 - - -# def install_rust(): -# """Install Rust if it's not already installed.""" -# if not check_command_exists("cargo"): -# subprocess.run( -# ["curl", "--proto", "=https", "--tlsv1.2", "-sSf", "https://sh.rustup.rs"], -# stdout=subprocess.PIPE, -# ) -# subprocess.run(["sh", "rustup-init", "-y"], check=True) -# else: -# print("Rust is already installed.") - - -# def install_docker(): -# """Install Docker if it's not already installed.""" -# if check_command_exists("docker"): -# print("Docker is already installed.") -# return True -# try: -# if os.name == "posix": -# plat = sys.platform -# if plat.startswith("linux"): -# subprocess.run(["sudo", "apt-get", "update"], check=True) -# subprocess.run( -# ["sudo", "apt-get", "install", "-y", "docker.io"], check=True -# ) -# elif plat == "darwin": -# subprocess.run(["brew", "install", "--cask", "docker"], check=True) -# else: -# sys.exit(f"Unsupported OS for Linux-like environments: {plat}") -# elif os.name == "nt": -# subprocess.run(["choco", "install", "docker-desktop"], check=True) -# else: -# sys.exit(f"Unsupported OS: {os.name}") -# return True -# except subprocess.CalledProcessError: -# return False - - -# def install_nvidia_toolkit(): -# """Install NVIDIA toolkit if on Linux.""" -# if sys.platform.startswith("linux"): -# subprocess.run(["sudo", "apt-get", "update"], check=True) -# subprocess.run( -# ["sudo", "apt-get", "install", "-y", "nvidia-container-toolkit"], check=True -# ) -# else: -# print("NVIDIA Container Toolkit is not supported on this OS.") - - -# def clone_and_install(repo_url, directory): -# """Clone a repository and run 'make install'.""" -# os.chdir(directory) -# subprocess.run(["git", "clone", repo_url], check=True) -# os.chdir(repo_url.split("/")[-1]) -# subprocess.run(["make", "install"], check=True) - - -# def run_docker_container(model, volume): -# """Run a Docker container with specified parameters.""" -# subprocess.run( -# [ -# "docker", -# "run", -# "-it", -# "--gpus", -# "all", -# "--shm-size", -# "1g", -# "-p", -# "8080:80", -# "-v", -# f"{volume}:/data", -# "ghcr.io/huggingface/text-generation-inference:latest", -# "--model-id", -# model, -# ], -# check=True, -# ) - - -# def main(): -# repo_url = "https://github.com/example/repo.git" -# directory = "/path/to/clone" -# use_docker = input("Do you want to use Docker? (yes/no): ").strip().lower() == "yes" - -# install_rust() -# if use_docker: -# print("Installing Docker...") -# if install_docker(): -# install_nvidia_toolkit() -# run_docker_container("HuggingFaceH4/zephyr-7b-beta", os.getcwd() + "/data") -# else: -# print("Failed to install Docker. Attempting to build from source.") -# clone_and_install(repo_url, directory) -# else: -# clone_and_install(repo_url, directory) - - -# if __name__ == "__main__": -# main() diff --git a/dockerinstaller/setup.py b/dockerinstaller/setup.py deleted file mode 100644 index 63d5845a..00000000 --- a/dockerinstaller/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="mydockerinstaller", - version="0.1", - packages=find_packages(), - entry_points={ - "console_scripts": ["mydockerinstaller = mydockerinstaller.installer:main"] - }, -)