Update binding.py

This commit is contained in:
Saifeddine ALOUI 2023-11-15 13:38:49 +01:00 committed by GitHub
parent 3f5f1ab517
commit 566491c2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,7 +12,6 @@ from typing import Callable
from lollms.paths import LollmsPaths
from ascii_colors import ASCIIColors
import tempfile
import requests
import shutil
@ -421,48 +420,7 @@ class LLMBinding:
full_data+=yaml_data
return full_data
@staticmethod
def check_torch_version(min_version):
import torch
# Extract torch version from __version__ attribute with regular expression
current_version_float = float('.'.join(torch.__version__.split(".")[:2]))
# Check if the current version meets or exceeds the minimum required version
return current_version_float >= min_version
@staticmethod
def reinstall_pytorch_with_cuda():
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir", "--index-url", "https://download.pytorch.org/whl/cu121"])
if result.returncode != 0:
ASCIIColors.warning("Couldn't find Cuda build tools on your PC. Reverting to CPU.")
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir"])
if result.returncode != 0:
ASCIIColors.error("Couldn't install pytorch !!")
else:
ASCIIColors.error("Pytorch installed successfully!!")
@staticmethod
def reinstall_pytorch_with_rocm():
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir", "--index-url", "https://download.pytorch.org/whl/rocm5.6"])
if result.returncode != 0:
ASCIIColors.warning("Couldn't find Cuda build tools on your PC. Reverting to CPU.")
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir"])
if result.returncode != 0:
ASCIIColors.error("Couldn't install pytorch !!")
else:
ASCIIColors.error("Pytorch installed successfully!!")
@staticmethod
def reinstall_pytorch_with_cpu():
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir"])
if result.returncode != 0:
ASCIIColors.warning("Couldn't find Cuda build tools on your PC. Reverting to CPU.")
result = subprocess.run(["pip", "install", "--upgrade", "torch", "torchvision", "torchaudio", "--no-cache-dir"])
if result.returncode != 0:
ASCIIColors.error("Couldn't install pytorch !!")
else:
ASCIIColors.error("Pytorch installed successfully!!")
@staticmethod
def vram_usage():