File size: 830 Bytes
fcbeb17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastapi import FastAPI, HTTPException,WebSocket, File, UploadFile
import os
import multiprocessing
import torch
app = FastAPI()
os.environ['CUDA_LAUNCH_BLOCKING'] = "1"

@app.get("/")
async def read_root():
    return {"Hello": "World"}
def worker():
    print(f"Worker process started with PID: {os.getpid()}")
print (__name__)
if __name__ == "app":
    print("Main process ID:", os.getpid())
    p = multiprocessing.Process(target=worker)
    p.start()
    p.join()
    print("in __main__")
    cuda_available = torch.cuda.is_available()
    print(f"CUDA Available: {cuda_available}")

    if cuda_available:
        print(f"Number of CUDA devices: {torch.cuda.device_count()}")
        print(f"CUDA Device Name: {torch.cuda.get_device_name(0)}")
    else:
        print("CUDA is not available. Check your installation.")