Trainer error 400: failing to pull image

This article explains how to resolve a common image-pull problem that can occur when running the custom PyTorch CPU runtime scenario in MLOps Studio Trainer.

Overview

In the custom PyTorch CPU runtime scenario, the training job may fail before the container starts. When this happens, log collection from the pod returns a 400 Bad Request response because Kubernetes cannot start the container successfully.

In the reported case, the root cause is an image that cannot be pulled. The fix is to replace the failing image reference with a working one and rerun the job.

When this issue appears

This issue may appear while following the scenario for using a custom PyTorch CPU runtime.

Instead of normal training logs, you may see an error similar to the following:

Logs from: pytorch-training-1764079788-master-0
======================================================================
Could not retrieve logs: (400)
Reason: Bad Request
...
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"container \"pytorch\" in pod \"pytorch-training-1764079788-master-0\" is waiting to start: trying and failing to pull image","reason":"BadRequest","code":400}

This message indicates that the pod exists, but the container cannot start because Kubernetes is unable to pull the image.

How to fix the problem

To resolve the issue, replace the failing image reference in the job definition.

Change this:

"image": "pytorch/pytorch:2.1.0-cpu"

to this:

"image": "pytorch/pytorch:latest"

Then run the job again. According to the source material, the job should work correctly with the updated image.

Step-by-step fix

Step 1. Follow the custom PyTorch CPU runtime scenario

Start with the same procedure as in the custom PyTorch CPU runtime scenario from the Trainer article.

Step 2. Check whether the image pull error appears

If the job fails and log retrieval returns the 400 Bad Request message shown above, treat it as an image-pull issue.

Step 3. Replace the image

Update the image field in the job definition:

"image": "pytorch/pytorch:latest"

This replaces the failing image reference with the working one identified in the source material.

Step 4. Run the job again

Submit the job again after updating the image.

Expected result

With the updated image, the training job should start normally and log retrieval should work as expected. The pod should no longer remain stuck in the image-pull phase.

What to do next

After fixing this issue, the next useful steps are:

  • rerun the custom PyTorch CPU runtime scenario,

  • verify pod status and logs again,

  • confirm that the training job reaches a normal running or completed state,

  • reuse the working image reference in similar Trainer tests.