Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Apr 7, 2023
1 parent f0efa5f commit 3d05773
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
19 changes: 18 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import sys
from typing import List
import os
import sysconfig
import time
import subprocess
import set_torch

from fastapi import FastAPI, Request, status, HTTPException
from pydantic import BaseModel
Expand All @@ -15,7 +15,24 @@
import uvicorn


def set_torch():
torch_path = os.path.join(sysconfig.get_paths()["purelib"], "torch\\lib")
paths = os.environ.get("PATH", "")
if os.path.exists(torch_path):
print(f"torch found: {torch_path}")
if torch_path in paths:
print("torch already set")
else:
print("run:")
os.environ['PATH'] = paths + os.pathsep + torch_path + os.pathsep
print(f'set Path={paths + os.pathsep + torch_path + os.pathsep}')
else:
print("torch not found")


def init_chatglm(chatglm):
set_torch()

import torch
from torch.cuda import get_device_properties
from transformers import AutoModel, AutoTokenizer
Expand Down
15 changes: 0 additions & 15 deletions set_torch.py

This file was deleted.

0 comments on commit 3d05773

Please sign in to comment.