Skip to content

Commit

Permalink
set devices to 0, default is 1 which fails when no GPU device available
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpfeifer committed Dec 15, 2024
1 parent 04fc625 commit f5004ec
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,27 @@ def test_continue_pretrain_model(tmp_path):

@pytest.mark.dependency(depends=["test_download_model"])
def test_serve():
CHECKPOINT_DIR = str("checkpoints" / REPO_ID)
CHECKPOINT_DIR = str("/Users/craig/code/litgpt/checkpoints" / REPO_ID)
run_command = [
"litgpt", "serve", str(CHECKPOINT_DIR)
"litgpt", "serve", "--devices","0", str(CHECKPOINT_DIR)
]

process = None

def run_server():
nonlocal process
try:
print (f"Running command {run_command}")
process = subprocess.Popen(run_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, stderr = process.communicate(timeout=60)
except subprocess.TimeoutExpired:
print (f"stdout : {stdout}")
print(f"stderr : {stderr}")
except subprocess.TimeoutExpired as te:
print('Server start-up timeout expired')
raise te
except Exception as e:
print (e)
raise e

server_thread = threading.Thread(target=run_server)
server_thread.start()
Expand All @@ -197,6 +204,7 @@ def run_server():
try:
response = requests.get("http://127.0.0.1:8000")
print(response.status_code)
print (response.text)
assert response.status_code == 200, "Server did not respond as expected."
finally:
if process:
Expand Down

0 comments on commit f5004ec

Please sign in to comment.