Skip to main content

Getting started

This page takes you through a first workload: a Python script that checks the GPU, trains for a few seconds and writes a result file. You need the GPU_WORKLOAD_MANAGE permission on a tenant provisioned for GPUs, see Getting access.

1. Write your script​

On your machine, create a scripts/ folder with this check_gpu.py:

scripts/check_gpu.py
import os
import torch

print("CUDA available:", torch.cuda.is_available())
print("GPU:", torch.cuda.get_device_name(0))

x = torch.randn(4096, 4096, device="cuda")
for _ in range(100):
x = torch.tanh(x @ x)
print("done")

output_dir = os.environ["GPUWL_OUTPUT_DIR"]
with open(os.path.join(output_dir, "result.txt"), "w") as f:
f.write(f"mean={x.mean().item()}\n")

GPUWL_OUTPUT_DIR is set by the platform to the output directory of the workload, /data/outputs/<workload-id>/. See the runtime environment.

2. Upload it to the tenant storage​

Open the Storage Access page of the portal: it shows the commands for each of your tenants, with your login and the tenant's path already filled in. From the folder that contains scripts/, connect with sftp:

sftp xavier.login@ssh.forge.epita.fr:/gpuwl/my-tenant/

Then, at the sftp> prompt, upload the folder and leave:

sftp> put -R scripts
sftp> exit

Your script is now at /data/scripts/check_gpu.py in every workload of the tenant. See Storage for more.

3. Submit the workload​

Open Submit Workload and fill in:

FieldValue
TenantYour tenant
Display namefirst workload
Imageregistry.cri.epita.fr/forge/docker/gpu-toolkit:1.0.0
Commandpython
Arguments/data/scripts/check_gpu.py
GPU typeOne of the types listed
GPU count1
Max duration0 hours 10 minutes

The Image field tells you whether the image is allowed for the tenant: the images a tenant may run are set by its GPU provisioning. Check the Summary on the right, then click Submit Workload. You land on the workload's page.

4. Follow it​

The workload's page shows its status, which changes on its own as the workload progresses:

  • Scheduled: it waits for a free GPU in your tenant's quota;
  • Admitted: a GPU is reserved, the image is being pulled;
  • Running: your command runs. The Logs tab shows its output live;
  • Succeeded: your command exited with code 0.

If it ends in Failed, the page shows the reason and the exit code. See Following a workload for every status and the usual causes of failure.

5. Fetch the results​

The Overview tab of the workload shows the commands to download its output directory. From the folder where you want the results:

sftp xavier.login@ssh.forge.epita.fr:/gpuwl/my-tenant/
sftp> get -R outputs/<workload-id> results
sftp> exit

results/result.txt now holds the result. The files stay in the tenant storage after you download them.

Next steps​

  • Use the Duplicate Workload button of a workload to submit it again, possibly with changes.
  • For a long workload, such as a training of several hours, save your progress regularly to files in /data (for instance the model's weights after each epoch), and make your script resume from the last saved state when it starts. If the workload fails or reaches its maximum duration, you can then submit it again without losing the work already done.