This commit is contained in:
Saifeddine ALOUI 2023-08-31 22:57:05 +02:00
parent bffd5735c1
commit 67e0c7a587

6
app.py
View File

@ -847,10 +847,16 @@ class LoLLMsWebUI(LoLLMsAPPI):
def upgrade_to_gpu(self):
ASCIIColors.yellow("Received command to upgrade to GPU")
ASCIIColors.info("Installing cuda toolkit")
res = subprocess.check_call(["conda", "install", "-c", "nvidia/label/cuda-11.7.0", "-c", "nvidia", "-c", "conda-forge", "cuda-toolkit", "ninja", "git", "--force-reinstall"])
if res!=0:
ASCIIColors.red("Couldn't install cuda toolkit")
return jsonify({'status':False, "error": "Couldn't install cuda toolkit. Make sure you are running from conda environment"})
ASCIIColors.green("Cuda toolkit installed successfully")
ASCIIColors.green("Installing pytorch with cuda support")
res = subprocess.check_call(["pip","install","--upgrade","torch==2.0.1+cu117", "torchvision", "torchaudio", "--index-url", "https://download.pytorch.org/whl/cu117"])
ASCIIColors.green("PyTorch installed successfully")
self.config.enable_gpu=True
return jsonify({'status':res==0})