Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
lizhiping
text-generation-inference
Commits
d3b62bf1
Commit
d3b62bf1
authored
1 year ago
by
drbh
Browse files
Options
Download
Email Patches
Plain Diff
fix: remove debug files from different branch
parent
f2d760ff
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
256 deletions
+0
-256
dockerinstaller/mydockerinstaller.egg-info/PKG-INFO
dockerinstaller/mydockerinstaller.egg-info/PKG-INFO
+0
-3
dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt
dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt
+0
-8
dockerinstaller/mydockerinstaller.egg-info/dependency_links.txt
...installer/mydockerinstaller.egg-info/dependency_links.txt
+0
-0
dockerinstaller/mydockerinstaller.egg-info/entry_points.txt
dockerinstaller/mydockerinstaller.egg-info/entry_points.txt
+0
-2
dockerinstaller/mydockerinstaller.egg-info/top_level.txt
dockerinstaller/mydockerinstaller.egg-info/top_level.txt
+0
-1
dockerinstaller/mydockerinstaller/__init__.py
dockerinstaller/mydockerinstaller/__init__.py
+0
-1
dockerinstaller/mydockerinstaller/installer.py
dockerinstaller/mydockerinstaller/installer.py
+0
-231
dockerinstaller/setup.py
dockerinstaller/setup.py
+0
-10
No files found.
dockerinstaller/mydockerinstaller.egg-info/PKG-INFO
deleted
100644 → 0
View file @
f2d760ff
Metadata-Version: 2.1
Name: mydockerinstaller
Version: 0.1
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller.egg-info/SOURCES.txt
deleted
100644 → 0
View file @
f2d760ff
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
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller.egg-info/dependency_links.txt
deleted
100644 → 0
View file @
f2d760ff
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller.egg-info/entry_points.txt
deleted
100644 → 0
View file @
f2d760ff
[console_scripts]
mydockerinstaller = mydockerinstaller.installer:main
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller.egg-info/top_level.txt
deleted
100644 → 0
View file @
f2d760ff
mydockerinstaller
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller/__init__.py
deleted
100644 → 0
View file @
f2d760ff
from
installer
import
run_docker_container
,
DockerThread
This diff is collapsed.
Click to expand it.
dockerinstaller/mydockerinstaller/installer.py
deleted
100644 → 0
View file @
f2d760ff
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()
This diff is collapsed.
Click to expand it.
dockerinstaller/setup.py
deleted
100644 → 0
View file @
f2d760ff
from
setuptools
import
setup
,
find_packages
setup
(
name
=
"mydockerinstaller"
,
version
=
"0.1"
,
packages
=
find_packages
(),
entry_points
=
{
"console_scripts"
:
[
"mydockerinstaller = mydockerinstaller.installer:main"
]
},
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment