Download app.py from saintbyte/first: direct link, hf CLI and curl.
- Browser
- Download file 564 Bytes
-
https://huggingface.co/spaces/saintbyte/first/resolve/965d9e4cc22abb8f3c55ca479698b8ebb0007cc6/app.py
- Command line
-
hf download hf://spaces/saintbyte/first@965d9e4cc22abb8f3c55ca479698b8ebb0007cc6/app.py
-
curl -L -o app.py https://huggingface.co/spaces/saintbyte/first/resolve/965d9e4cc22abb8f3c55ca479698b8ebb0007cc6/app.py
564 Bytes
| import gradio as gr | |
| import spaces | |
| import torch | |
| zero = torch.Tensor([0]).cuda() | |
| print(zero.device) # <-- 'cpu' 🤔 | |
| def greet(n): | |
| print(zero.device) # <-- 'cuda:0' 🤗 | |
| if torch.cuda.is_available(): | |
| total_memory_bytes = torch.cuda.get_device_properties(0).total_memory | |
| gb = total_memory_bytes / (1024**3) | |
| print(f"VRAM 0: {gb:.2f} GB" | |
| else: | |
| print("CUDA is NOT available") | |
| return f"Hello {zero + n} Tensor" | |
| demo = gr.Interface(fn=greet, inputs=gr.Number(), outputs=gr.Text(), share=True) | |
| demo.launch() | |