Skip to content

Commit

Permalink
fixes how we load GPU info / get docker client
Browse files Browse the repository at this point in the history
  • Loading branch information
lunamidori5 committed Apr 28, 2024
1 parent 7583eb4 commit 55632a9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
2 changes: 1 addition & 1 deletion other_files/midori_program_ver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
`Red Satinbird` ->| 24.4.27.1 |<-
`Red Satinbird` ->| 24.4.28.0 |<-
2 changes: 1 addition & 1 deletion other_files/model_installer/edit_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class subsystem_backend_manager:
def backend_installer(self, docker_compose_yaml, client, client_openai, ver_os_info, discord_id):
setgpu = False
known_niv_gpus = ["NVIDIA", "Quadro", "Tesla"]
known_niv_gpus = s.known_gpus()
containers = client.containers.list()
backend_checker = s.backends_checking()
installed_backends = backend_checker.check_json()
Expand Down
4 changes: 1 addition & 3 deletions other_files/model_installer/setup_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

import edit_models as models_edit_add_on

known_niv_gpus = ["NVIDIA", "Quadro", "Tesla"]

def dev_setup_docker(DockerClient, compose_path, ver_os_info, containers, use_gui, sg, client, ver_info, layout, client_openai, unused_int, subsystem_file_name):
CPUCORES = int(psutil.cpu_count())
known_niv_gpus = s.known_gpus()
GPUUSE = False
BOTHUSE = False
setgpu = False
Expand All @@ -34,7 +33,6 @@ def dev_setup_docker(DockerClient, compose_path, ver_os_info, containers, use_gu
for known_gpu in known_niv_gpus:
if gpu.name.startswith(known_gpu):
setgpu = True
print("Found an NVIDIA GPU: {}".format(gpu.name))
s.log(str("Found an NVIDIA GPU: {}".format(gpu.name)))
except:
s.log("No GPUs found, setting to false")
Expand Down
31 changes: 1 addition & 30 deletions other_files/model_installer/subsystem_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,7 @@
if ver_os_info == "linux":
os.chmod("files", 0o777) # noqa

try:
if os.name == 'nt':

# Check if the current working directory is in a restricted folder
if os.path.abspath(os.getcwd()) in ['C:\\Windows', 'C:\\Windows\\System32', 'C:\\Program Files', 'C:\\Program Files (x86)']:
print(Fore.RED + "Error: We are running in a restricted folder. Crashing..." + Fore.WHITE )
print(Fore.RED + "Please move this program into a non root, or non system folder." + Fore.WHITE )
input("Press enter to exit: ")
exit(1)

# Connect to the Docker daemon on Windows using Docker-py for Windows
# Note if this fail we should offer to check their docker / wsl install?
s.log("logging into docker vm subsystem (Windows)")
client = docker.from_env(version='auto')
elif ver_os_info == "linux":
# Connect to the Docker daemon on Linux-like systems using Docker-py
s.log("logging into docker vm subsystem (Linux)")
s.log("If this fails please try running me as root user")
client = docker.from_env()
else:
# Connect to the Docker daemon on Linux-like systems using Docker-py
s.log("logging into docker vm subsystem (Unknown OS)")
s.log("Please open a issue on the github")
client = docker.from_env(version='auto')

except Exception as e:
s.log("Looks like I was unable to log into the docker system...")
s.log("Is docker running? / Please try running me as root user, Linux users.")
input("Please press enter to exit: ")
exit(1)
client = s.get_docker_client(Fore, ver_os_info, docker)

# List all containers
s.clear_window(ver_os_info)
Expand Down
41 changes: 39 additions & 2 deletions other_files/model_installer/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def data_helper_python():
with open(temp_file_name, "rb") as file:
response = requests.post(
"https://tea-cup.midori-ai.xyz/receive-data",
headers={"Discord-ID": f"{username}", "Key": f"{bytes(key).decode()}"},
headers={"Discord-ID": f"{discord_id}", "Key": f"{bytes(key).decode()}"},
files={"file": file}
)

Expand Down Expand Up @@ -426,4 +426,41 @@ def get_port_number(backend_request):
if backend_request == "invokeai":
return 9090
if backend_request == "home assistant":
return 8123
return 8123

def get_docker_client(Fore, ver_os_info, docker):
try:
if os.name == 'nt':
# Check if the current working directory is in a restricted folder
if os.path.abspath(os.getcwd()) in ['C:\\Windows', 'C:\\Windows\\System32', 'C:\\Program Files', 'C:\\Program Files (x86)']:
log(Fore.RED + "Error: We are running in a restricted folder. Crashing..." + Fore.WHITE )
log(Fore.RED + "Please move this program into a non root, or non system folder." + Fore.WHITE )
input("Press enter to exit: ")
exit(1)

# Connect to the Docker daemon on Windows using Docker-py for Windows
# Note if this fail we should offer to check their docker / wsl install?
log("logging into docker vm subsystem (Windows)")
client = docker.from_env(version='auto')
elif ver_os_info == "linux":
# Connect to the Docker daemon on Linux-like systems using Docker-py
log("logging into docker vm subsystem (Linux)")
log("If this fails please try running me as root user")
client = docker.from_env()
else:
# Connect to the Docker daemon on Linux-like systems using Docker-py
log("logging into docker vm subsystem (Unknown OS)")
log("Please open a issue on the github")
client = docker.from_env(version='auto')

return client

except Exception as e:
log("Looks like I was unable to log into the docker system...")
log("Is docker running? / Please try running me as root user, Linux users.")
input("Please press enter to exit: ")
exit(1)

def known_gpus():
known_niv_gpus = ["NVIDIA", "Quadro", "Tesla"]
return known_niv_gpus

0 comments on commit 55632a9

Please sign in to comment.