setup train
Browse files- check_space.py +37 -0
- train_hugg.py +32 -0
- train_job.py +19 -0
check_space.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from huggingface_hub import HfApi
|
| 2 |
+
|
| 3 |
+
# my_token = """
|
| 4 |
+
# api = HfApi(token=my_token)
|
| 5 |
+
|
| 6 |
+
# spaces = api.list_spaces(author="uav-vts") # hoặc namespace bạn được cấp
|
| 7 |
+
# for space in spaces:
|
| 8 |
+
# print(space.id, getattr(space, "private", "N/A"), getattr(space, "sdk", "N/A"))
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
from huggingface_hub import HfApi
|
| 12 |
+
|
| 13 |
+
my_token = ""
|
| 14 |
+
|
| 15 |
+
my_namespace = "uav-vts"
|
| 16 |
+
|
| 17 |
+
api = HfApi(token=my_token)
|
| 18 |
+
|
| 19 |
+
spaces = api.list_spaces(author=my_namespace)
|
| 20 |
+
|
| 21 |
+
if not spaces:
|
| 22 |
+
print("Không tìm thấy Space nào trong namespace / resource group này.")
|
| 23 |
+
else:
|
| 24 |
+
print(f"Tìm thấy {len(list(spaces))} Space(s) trong namespace '{my_namespace}':\n")
|
| 25 |
+
for space in spaces:
|
| 26 |
+
owner, name = space.id.split("/") if "/" in space.id else ("unknown", space.id)
|
| 27 |
+
url = f"https://huggingface.co/spaces/{space.id}"
|
| 28 |
+
private = getattr(space, "private", "N/A")
|
| 29 |
+
sdk = getattr(space, "sdk", "N/A")
|
| 30 |
+
last_modified = getattr(space, "lastModified", "N/A")
|
| 31 |
+
# Trạng thái có thể lấy từ cardData nếu expand=["cardData"]
|
| 32 |
+
status = getattr(getattr(space, "cardData", {}), "status", "N/A")
|
| 33 |
+
|
| 34 |
+
print(f"Owner: {owner}, Name: {name}")
|
| 35 |
+
print(f"URL: {url}")
|
| 36 |
+
print(f"Private: {private}, SDK: {sdk}, LastModified: {last_modified}, Status: {status}")
|
| 37 |
+
print("-" * 60)
|
train_hugg.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from huggingface_hub import HfApi
|
| 2 |
+
|
| 3 |
+
# api = HfApi()
|
| 4 |
+
|
| 5 |
+
# job = api.create_job(
|
| 6 |
+
# repo_id="uav-vts/training_sem",
|
| 7 |
+
# docker_image="pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel",
|
| 8 |
+
# command="python runner/train.py",
|
| 9 |
+
# hardware="a100",
|
| 10 |
+
# # token="<TOKEN>"
|
| 11 |
+
# )
|
| 12 |
+
|
| 13 |
+
# print("Job created:", job.job_id)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
from huggingface_hub import run_job
|
| 17 |
+
|
| 18 |
+
image = "pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel"
|
| 19 |
+
command = [
|
| 20 |
+
"python",
|
| 21 |
+
"-c",
|
| 22 |
+
"import torch; print(f'This code ran with the following GPU: {torch.cuda.get_device_name()}')"
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
job = run_job(
|
| 26 |
+
image=image,
|
| 27 |
+
command=command,
|
| 28 |
+
flavor="a100-large",
|
| 29 |
+
namespace="uav-vts"
|
| 30 |
+
)
|
| 31 |
+
print("Job submitted!")
|
| 32 |
+
print("Track it here:", job.url)
|
train_job.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import run_job
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# docker pull pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel
|
| 5 |
+
job = run_job(
|
| 6 |
+
image="pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel",
|
| 7 |
+
command=[
|
| 8 |
+
"bash",
|
| 9 |
+
"-c",
|
| 10 |
+
"apt-get update && apt-get install -y git && "
|
| 11 |
+
"git clone https://huggingface.co/uav-vts/training_sem . && "
|
| 12 |
+
"pwd && ls -al && "
|
| 13 |
+
"pip install -r requirements.txt && "
|
| 14 |
+
"python runner/train.py"
|
| 15 |
+
],
|
| 16 |
+
flavor="a100-large",
|
| 17 |
+
namespace="uav-vts"
|
| 18 |
+
# token="hf_xxx"
|
| 19 |
+
)
|