Skip to content
qgonDEV DOCSSDK 0.3.31
ENKR

Run training on the GPU queue

In the appBuild › SchedulingExamples checked on SDK 0.3.29

Send training code you edited in a workspace to the server's GPU queue with one command. After reading this page you can check what will be uploaded, watch the run until it ends, and judge the result by its exit code. It also covers sending runs from the UI without a terminal and re-running finished runs.

A run you send first waits in a queue. The training queue is called gpu. Agents on the server take runs from the queue one at a time, start a container and run it on the GPU. One agent runs one run at a time. Queue order and start conditions are in Share GPUs and the queue. Terms are in Concepts.

Runs sent to a queue are recorded like any other experiment. Arguments, logs, graphs, models and GPU utilization collect in Build › Experiments.

  1. In a workspace terminal, go to the top folder of your project.

    cd ~/my-project
  2. Check what will be uploaded first. --dry-run only shows the files to upload, the files left out, the packages to install, and the queue and team. It sends nothing.

    qgon run --queue gpu --dry-run -- python train.py --lr 0.01
  3. Send it. The run id and its page address are printed.

    qgon run --queue gpu --project vision -- python train.py --lr 0.01
  4. To follow the log until the end, add --wait. When the run ends, the command exits with the run's exit code.

    qgon run --queue gpu --wait -- python train.py --lr 0.01

Put qgon options before -- and the script command after it. If you put an option after the script, as in qgon run python train.py --queue gpu, it becomes a script argument. The run then does not go to the queue. It runs in the current workspace and a warning is shown. --project, --name and --tags are common script argument names too, so after the script they pass to it without a warning.

With --remote instead of --queue, the run goes to the default queue. The default queue is gpu and you change it with the QGON_QUEUE environment variable. If an admin has closed a queue to members, sending to it stops before any code is uploaded. The message then lists the queues you can use.

Option What it does
--queue QUEUE Send to this queue
--remote Send to the default queue
--project P --name N --tags a,b Project, name and tags of the experiment. Without a project, the QGON_PROJECT environment variable is used, then Default
--packages a,b Extra packages to install. You can repeat it and give version ranges such as "numpy>=1.20,<2"
--no-requirements Do not install packages from requirements.txt or pyproject.toml
--env VERSION Run with an environment saved in a workspace (below)
--image IMAGE Run with a job image an admin allowed. Only images derived from the server job image work. Cannot be combined with --env
--team TEAM The team this run counts toward. Only teams you belong to
--wait Follow the log and exit with the run's exit code
--timeout SECONDS Wait only this long with --wait. After that the command exits with 124 and the run keeps going
--dry-run Show what would be uploaded without sending
--json Write one JSON result line as the last line of standard output, for scripts. Cannot be combined with --dry-run
--draft Create a draft without queueing it. Used as the source of a pipeline step
--task-type Run type: training (default), data_processing or custom

The full help is in the qgon command reference.

If the current folder is inside a git repository, the top of the repository is the base. Committed files are uploaded, plus uncommitted changes and new files not yet added to git. Files matched by .gitignore are left out. New files are listed when you send. The commit, branch and uncommitted changes (diff) are recorded with the run.

Outside a git repository, the current folder is uploaded. If a folder above it has a .qgonignore, the nearest such folder becomes the base. That is why you put an empty .qgonignore in the top folder when sending from a subfolder.

To leave out more files, list them in .qgonignore in the base folder. The syntax is the same as .gitignore.

Secret files are always left out, and .qgonignore cannot bring them back.

  • .env, .envrc, .netrc, .git-credentials, .pypirc
  • Keys and certificates: *.pem, *.key, *.p12, id_rsa, id_ed25519 and so on (public keys *.pub are uploaded)
  • The SDK config file qgon.conf, kaggle.json, and credential files such as credentials.json and secrets.yaml
  • Files with credential or secret in the name. Source code (.py, .ipynb) and docs (.md) are not left out
  • Folders such as .ssh, .aws, .docker, .kube, .git and secrets

The following are left out by default, but !path in .qgonignore uploads them.

  • Virtual environment, cache and build folders: .venv, venv, __pycache__, node_modules, .cache, wandb, lightning_logs and so on
  • Checkpoint and weight extensions: .pt, .pth, .ckpt, .safetensors, .onnx, .h5 and so on

Symbolic links, git submodules and repositories nested inside the repository, and files over 10MB are not uploaded either. If the total goes over 200MB or 10,000 files, nothing is sent. You can change these limits with environment variables (Configuration and environment variables). Do not send data with your code. Make it a dataset and read it with qgon.dataset() (Datasets).

Unless you choose otherwise, the run uses the server job image. It contains torch, CUDA and the qgon SDK, with the same torch and CUDA versions as the default workspace image. Job code can use qgon.dataset(), qgon.model() and the mounted dataset folders as they are.

If there is a requirements.txt, it is installed before the script starts. Without one, the dependencies in pyproject.toml are installed. Lines for torch, nvidia-* and the SDK in a pip freeze list are skipped and the image's copies are used. Any other demand for torch, CUDA or SDK versions different from the image stops the install step (exit code 4).

If the server cannot reach the internet, packages that are not in the image cannot be installed. In that case skip installation with --no-requirements, or save the environment you set up in a workspace and send with --env. Ask an admin to add packages to the job image.

A version saved with Save environment in a workspace is used as the job image as it is. It already has the packages installed in the workspace, so nothing is installed again at run time. Saving environments is covered in Workspaces and environments.

qgon run --queue gpu --env 3 -- python train.py # v3 of the current workspace (3 and v3 are the same)
qgon run --queue gpu --env team-a:v3 -- python train.py # v3 of another workspace, team-a

Write the version only as 3 or v3. v03 and V3 stop with a format error before sending. Only members of a workspace can use its environments. If the version does not exist or you lack permission, the server refuses. The run being created and the uploaded code are then deleted. --env cannot be combined with --image.

In the UI, click Train with this next to an environment version on the workspace detail page. The New run screen opens with that version selected.

On a server with teams, --team decides which team's quota this run counts toward. Without it, the server decides. A run sent from a team workspace counts toward that team, and other runs toward your primary team. If you do not belong to the team, or the team cannot use this queue, the command stops before sending. Quotas are covered in Teams and quotas.

qgon.submit() uploads the code in the current folder with the same rules as qgon run --queue and puts it on a queue. To upload another folder, pass cwd=.

import qgon
r = qgon.submit(["python", "train.py", "--lr", "0.01"], queue="gpu", project="vision")
print(r.id, r.url)
code = r.wait() # follows the log and returns the exit code

Argument names match the command options: packages, requirements=False (--no-requirements), env, image, team, draft and task_type. If the run cannot be sent, it raises qgon.SubmitError with the reason as a Korean message.

On the returned RemoteRun, status() gives the current status, and exit_code() gives the exit code once the run has ended, or None before that. wait(timeout=600) raises TimeoutError after the time limit. If you stop waiting (Ctrl-C), the run keeps going.

A command waiting with --wait, and RemoteRun.wait(), return the run's result as an exit code.

Code Meaning
0 Completed
n The script ended with sys.exit(n)
1 The script raised an exception
3 The code bundle could not be fetched or unpacked (setup step)
4 Packages could not be installed
5 The run left the queue and went back to draft
75 The run status could not be read from the server for about 10 minutes. The run may still be going. A run that ended by yielding the GPU also ends with 75
124 --timeout was exceeded. The run keeps going
130 The run was stopped, or you pressed Ctrl-C while waiting (the run then keeps going)

124 is used only by the command. In the same case, Python's wait() raises TimeoutError. If the status cannot be read for a long time, it raises qgon.SubmitError. Whether a script ended with 3 or 4 itself or the setup step failed is shown on the Experiments page, where the failure reason names the step. Runs that end by yielding are covered in Checkpoints and resume.

Without a terminal, use New run in Build › Scheduling. Run with this workspace on a workspace detail page opens the same screen.

  1. Workspace: choose the workspace with your code. It must be running, and you must have clicked Set up access in it once. If something is missing, the screen tells you what to do.

  2. Environment: choose an environment version saved in that workspace. If there is none, save the environment in the workspace first.

  3. Code: under your home folder, choose the code folder and the target to run (such as train.py). You can also run a module.

  4. Parameters: enter names and values. They are passed to the code as --name=value arguments. If you read them with argparse, they are also recorded as experiment settings.

  5. Dataset (optional): choosing a mounted version records that this run used the data. In code, read it with qgon.dataset("name", version="…").

  6. Queue: only queues with an agent to take the run are shown. On a server with teams, also choose the Quota team.

  7. Enter a project and run name (optional) and click Run. Packing and sending the code takes a little while.

Runs always run under your own account. Even admins cannot send runs as someone else. If sending fails, the screen shows the reason and how to fix it.

New run screen with the workspace, saved environment, code and parameter steps. The environment step shows a notice because no environment has been saved yet
Step 2, Saved environment, shows a notice because no environment has been saved yet. Save one on the Environment tab of the workspace screen.View full size(opens in a new tab)

To run a finished run again with changed settings, click Re-run with changes on the Experiments page or in the Scheduling Recently finished tab. The New run screen opens, filled with the run's workspace, environment version, code folder, target, parameters, dataset, queue and project. The name gets '(again)' at the end. If a value cannot be used now, such as a stopped workspace or a deleted environment version, that step is marked red so you can choose again.

This is available only for runs created from the New run screen or with qgon run --queue. Hyperparameter search and pipeline groups cannot be re-run as a whole, so expand them and pick one trial. LLM fine-tuning runs are restarted from the fine-tuning screen.

Build › Scheduling shows runs that went through a queue in three tabs. It refreshes every 10 seconds. Click Refresh now to see changes at once. At the top, filter by My runs or Everyone (plus My team when there are teams), by queue and by workspace.

  • Waiting: shows the position and the wait reason. Remove your own runs with Cancel waiting. A removed run stays in the experiment records as a draft. How to read wait reasons is in Share GPUs and the queue.
  • Running: shows which agent runs it, start time and elapsed time, progress and time left, and current and peak GPU memory. Progress shows only if the code records it. Stop halts training at once. Logs, graphs and files recorded up to then stay in the experiment records.
  • Recently finished: shows up to 50 runs that ended in the last 24 hours. Find older runs on the Experiments page. Open Why failed on a failed row to see the exit reason and the last console lines. The cause is usually in the last line. Open full console goes to the experiment's log.

A stopped run cannot continue where it was. If it saved checkpoints, start a new run with Resume training. Without checkpoints, re-run it. Cancel waiting and Stop work only on your own runs. Team leads can also stop running jobs of team members. Admins can handle every run.

Scheduling page with the Running tab and the GPU memory (unified) bar
The Running tab. Each row shows queue and agent, start and elapsed time, progress and time left and GPU memory, with Stop at the right end.View full size(opens in a new tab)
  • Distributed training across several GPUs or nodes (torchrun, DDP) is not supported. Training jobs cannot talk to each other.
  • Only Python scripts and modules can be sent. Other commands cannot.
  • Training jobs cannot reach ports opened by other users' jobs. They also cannot reach servers, NAS or internal git at private addresses on the company network. If you need an internal mirror, ask an admin to add an exception. Network rules are in Security and access.