Spaces:
Build error
Build error
Download cuda_multi_processing_test.py from zmbfeng/video_stream: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/spaces/zmbfeng/video_stream/resolve/main/cuda_multi_processing_test.py
- Command line
-
hf download hf://spaces/zmbfeng/video_stream/cuda_multi_processing_test.py
-
curl -L -o cuda_multi_processing_test.py https://huggingface.co/spaces/zmbfeng/video_stream/resolve/main/cuda_multi_processing_test.py
830 Bytes
| from fastapi import FastAPI, HTTPException,WebSocket, File, UploadFile | |
| import os | |
| import multiprocessing | |
| import torch | |
| app = FastAPI() | |
| os.environ['CUDA_LAUNCH_BLOCKING'] = "1" | |
| 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.") | |