← SHANNONWAREARTICLE · 2026.12.04

Notebook Execution Hang Issue

24 NOV 2026

Initial Query

Shannon: <context> I am running this Jupyter Notebook in Visual Studio Code. The cell execution appears to be hing at the cell

import sys
from pathlib import Path
</context> <inputs> <input index="1"> C:\Users\safetystation\Documents\production-ai-agents-for-media-generation\01-consistent-media-generation-on-serverless-gpus\code\nb-first-generation-local.ipynb </input> <input index="2"> https://github.com/DataTalksClub/production-ai-agents-for-media-generation/blob/main/01-consistent-media-generation-on-serverless-gpus/02-first-generation.md </input> </inputs> <query> Please help me diagnose the issue with this notebook execution. </query>

Claude: The import sys cell isn't hanging. It's the first cell you ran, so it's waiting for a Jupyter kernel that never starts. Any cell would stop at the same spot.

Why the kernel can't start

| Check | What I found | |---|---| | Python on this machine | Only 3.14.4 | | Python the repo supports | requires-python = ">=3.12,<3.14" in pyproject.toml, so 3.14 is outside it | | ipykernel in that Python | Not installed (ModuleNotFoundError) | | Project virtual env (.venv) | Doesn't exist. The repo uses uv (uv.lock), but uv isn't installed | | Registered Jupyter kernels | None |

The notebook's kernel setting is just a generic "Python 3". VS Code points that at your system Python 3.14, which has no ipykernel, so the cell sits on its spinner. The output panel usually shows a kernel-start error or an "install ipykernel?" prompt that's easy to miss.

The saved outputs in the notebook came from the course author's Mac (paths like /Users/mnrozhkov/...). They don't show that it ever ran on your machine.

Fix, from the repo root (production-ai-agents-for-media-generation):

  1. Install uv:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. Open a new terminal, then create the environment. uv downloads a compatible Python 3.13 on its own:
uv sync --extra notebooks
  1. In VS Code, click the kernel picker at the top right of the notebook. Choose Select Another Kernel → Python Environments and pick .venv\Scripts\python.exe from the repo.
  2. Restart the kernel and run the cells from the top.

You don't need the gpu extra on your laptop. This notebook only calls the remote Endpoint.

One more thing: the next cell (setup_endpoint()) asks for the URL and token with an input box at the top of VS Code. If execution seems stuck there, look for that prompt.

Shall I install uv and set up the project's .venv kernel for you?

The cell isn't really hanging: the Jupyter kernel never starts. Your only Python is 3.14 with no ipykernel, there's no project .venv, and the repo needs Python 3.12–3.13. Nothing has been installed or changed yet.

Yes, set it up I'll do it myself

I'll do it myself

Shannon: I'll do it myself

Sounds good. Once you've done step 3, the kernel name at the top right of the notebook should show the .venv environment, not "Python 3.14". When you run the import sys cell, it should finish almost at once with an execution number like [1].

If it still spins, send me what the Output panel shows for Jupyter (choose it from the dropdown there) and I'll take a look.

<python> # reload(image) keeps share_card already imported by that module. importlib.reload(share_card_module) importlib.reload(image) from common import asset_record, metrics, output_dir, setup_endpoint, wait_ready, write_json from image import ImageGenerator, cached_image, image_comparison, share_card

BASE_URL, TOKEN = setup_endpoint() </python> <query> Is it waiting for input from me? </query>

Claude: Yes, it's very likely waiting for you. There's no code/.env file yet, so setup_endpoint() will ask for two things, one after the other:

  1. Endpoint HTTPS URL:: paste your Endpoint's URL from the Nebius console (starting https://) and press Enter.
  2. Endpoint token:: paste the token and press Enter. It uses getpass, so the token won't show as you paste. That's expected.

In VS Code these prompts appear as an input box at the top of the window, in the command-palette area, not inside the notebook. It's easy to miss, and if it loses focus it can vanish while the cell keeps spinning. If you can't see it, click the notebook and look at the top of the screen. If it's gone, interrupt the kernel (the ■ button) and run the cell again.

Once you've entered both, they're saved to code/.env, so later runs won't ask again.

HTTPError

Shannon: The output for the previous cell now says "Endpoint configured (***kew2) ". However, when I run the next cell

models = wait_ready(BASE_URL, TOKEN, deadline_s=600)
print("Served models:", [m.get("id") for m in models["data"]])

it gives and HTTPError .

Claude: It's an HTTP 404, and it comes from Nebius's tunnel, not from the model server. I sent a request to your Endpoint URL without the token, and Nebius's proxy answered:

HTTP/1.1 404 Not Found
Proxy-Status: nebius-tunnel; error=proxy_internal_response; details="unknown_tunnel"

A made-up hostname on the same domain gets exactly the same reply. So Nebius doesn't currently know a tunnel at https://port8000-jxcws3qypmkk60a.tunnel.applications.eu-west2.nebius.cloud. The request never reaches your model, so the token isn't the issue yet.

wait_ready only retries 429/502/503/504, the "still starting up" errors. A 404 is raised straight away, which is why the cell stopped with HTTPError.

Likely causes, most likely first:

  1. The Endpoint isn't RUNNING. It may be stopped, preempted, still provisioning, or deleted. Check its status in the Nebius console.
  2. The URL is from a different Endpoint, for example an earlier one you deleted and recreated. Each Endpoint gets a new tunnel hostname.
  3. A typo in the pasted URL. Compare it character by character with the one in the console.

To fix it:

  • Once the console shows RUNNING, copy its HTTPS URL. If it matches the one above, just re-run the wait_ready cell.
  • If the URL has changed, open code/.env and delete the BASE_URL line. If it's a new Endpoint, delete the TOKEN line too. Then restart the kernel and run the cells again from the top. Step 1 will ask for the new values.

After the URL is right, you may see 502 for a few minutes while the model loads. The cell waits through that by itself.

What is the actual endpoint token?

Shannon: The endpoint is restarting. In the mean time, a question: In the Nebius console endpoint details page, is it the string of characters beginning with "tenantuseraccount-" that appears underneath my name, that is the actual endpoint token?

Claude: No. The tenantuseraccount-… string under your name is your Nebius user account ID. It identifies who you are in the console, and it isn't a secret.

The Endpoint token is the one you generated in the Endpoint form when you created it. The course guide says it's shown only once, before you click Create, and you have to copy it then.

That matters right now. I checked the token saved in code/.env, looking only at its first characters and printing nothing else. It does start with tenantuseraccount-, so the notebook has your account ID stored as the token. Once the URL problem is fixed, you'd get 401 or 403 errors next.

To fix it:

  • If you still have the real token from when you created the Endpoint: delete the TOKEN= line from code/.env, restart the kernel and run the cells from the top. Paste the real token when it asks.
  • If you didn't save it: the guide says you have to create a new Endpoint and copy its token this time. A new Endpoint also gets a new URL, so delete both the BASE_URL= and TOKEN= lines from code/.env before re-running. Stop or delete the old Endpoint so it doesn't keep billing.

Reference to Instructor Example

Shannon: I have deleted the endpoint. What is the URL of the instructor repository document that describes exactly how to set up a Nebius endpoint?

Claude: The setup steps are in the lesson guide you linked at the start. Look for the section on creating the Endpoint, around line 48:

https://github.com/DataTalksClub/production-ai-agents-for-media-generation/blob/main/01-consistent-media-generation-on-serverless-gpus/02-first-generation.md

The same file is in your local clone at 01-consistent-media-generation-on-serverless-gpus\02-first-generation.md.

The guide links to two more pages for the setup:

  • Sana template in the console (opens the Endpoint form already filled in: one L40S GPU, preemptible VM, token authentication): https://console.nebius.com/serverless/endpoint/create?template=sana
  • Sana template README in Nebius's cookbook: https://github.com/nebius/serverless-ai-cookbook/blob/main/templates/endpoint-sana/README.md

This time, generate the token in the form and copy it before you click Create. Then delete the BASE_URL= and TOKEN= lines from code/.env, restart the kernel, and run the notebook from the top.

Shannon: <context> I created a new endpoint, then copied the endpoint and the token into the code\.env file. I restarted the kernal. Starting from the top, I re-ran all cells. This same cell ran for 24.5 seconds before yielding an HTTPError .

<python> models = wait_ready(BASE_URL, TOKEN, deadline_s=600) print("Served models:", [m.get("id") for m in models["data"]]) </pyton> <output> Generated in 1.2 s Saved /Users/mnrozhkov/dev/course_media_agent/production-ai-agents-for-media-generation/01-consistent-media-generation-on-serverless-gpus/code/runs/first-image.png

Generated in 1.2 s Generated in 1.2 s

Identical: False

Generated in 1.2 s Generated in 1.5 s

Generated in 1.3 s

Endpoint configured (***i4kg)

* * *

HTTPError Traceback (most recent call last) Cell In[5], line 1 ----> 1 models = wait_ready(BASE_URL, TOKEN, deadline_s=600) 2 print("Served models:", [m.get("id") for m in models["data"]])

File ~\Documents\production-ai-agents-for-media-generation\01-consistent-media-generation-on-serverless-gpus\code\common.py:122, in wait_ready(base, token, deadline_s) 117 raise TimeoutError( 118 f"Readiness deadline reached (last error: {last_error}); " 119 "inspect logs and stop the Endpoint" 120 ) 121 try: --> 122 data = request(base, token, "/v1/models", timeout=min(30, remaining)) 123 if isinstance(data, dict) and isinstance(data.get("data"), list) and data["data"]: 124 return data

File ~\Documents\production-ai-agents-for-media-generation\01-consistent-media-generation-on-serverless-gpus\code\common.py:103, in request(base, token, route, body, timeout) 97 headers["Content-Type"] = "application/json" 98 req = urllib.request.Request( 99 base.rstrip("/") + route, 100 headers=headers, 101 data=None if body is None else json.dumps(body).encode(), 102 ) --> 103 with urllib.request.urlopen(req, timeout=timeout) as response: 104 return json.load(response) ... File ~\AppData\Roaming\uv\python\cpython-3.13-windows-x86_64-none\Lib\urllib\request.py:613, in HTTPDefaultErrorHandler.http_error_default(self, req, fp, code, msg, hdrs) 612 def http_error_default(self, req, fp, code, msg, hdrs): --> 613 raise HTTPError(req.full_url, code, msg, hdrs, fp)

HTTPError: HTTP Error 404: Not Found Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

<output> The new URL and token are saved correctly. The token is 16 characters and no longer your account ID. But the new Endpoint has the same problem as before. I tried its URL just now, without the token, and Nebius answered:
404 "No tunnel has this address."  reason: unknown_tunnel, scope: pod

The 24.5 seconds is a useful clue. wait_ready only keeps polling on "still starting" errors (502/503/504/429), and a 404 stops it at once. So for about 20 seconds the Endpoint was answering, most likely with 502 while the model loaded. Then the tunnel disappeared. That means the Endpoint's pod (its container) stopped running soon after it started.

Check in the Nebius console, on the new Endpoint's page:

  1. Status. It's probably no longer RUNNING.
    • STOPPED with code Preempted: Nebius took the cheap preemptible GPU back. Start it again; it won't restart on its own. The URL stays the same, so code/.env is still fine.
    • ERROR, or it keeps restarting: open the Endpoint's Logs and look at the last lines. A crash while loading the model (for example, running out of memory or disk) shows up there.
    • NotEnoughResources: no free GPU right now. Try later or in another region.
  2. If it's preempted again and again, create the Endpoint with preemptible turned off. It costs more per hour, but it won't be taken away mid-lesson.

When the console shows RUNNING again, just re-run the wait_ready cell. There's no need to restart the kernel or re-enter anything.

The Generated in 1.2 s and /Users/mnrozhkov/... lines in your output aren't from your run. They're saved outputs from the course author's Mac, still in the notebook file, so you can ignore them.

If the status or logs show something other than the cases above, paste the last few lines of the log here.

Shannon: The status was ERROR. I have restarted it. While we wait, here are the logs

24 Nov 12:34:24.880 Provisioning resources for the workload 24 Nov 12:21:42.691 ERROR: Application startup failed. Exiting. 24 Nov 12:21:42.618 24 Nov 12:21:42.618 24 Nov 12:21:42.618 For more detailed error information, run with CUDA_LOG_FILE=stderr 24 Nov 12:21:42.618 Search for `cudaErrorNoKernelImageForDevice' in https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html for more information. 24 Nov 12:21:42.618 torch.AcceleratorError: CUDA error: no kernel image is available for execution on the device 24 Nov 12:21:42.618 ^^^^^ 24 Nov 12:21:42.618 return t.to( 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1369, in convert 24 Nov 12:21:42.618 ^^^^^^^^^ 24 Nov 12:21:42.618 param_applied = fn(param) 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 964, in _apply 24 Nov 12:21:42.618 module._apply(fn) 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 933, in _apply 24 Nov 12:21:42.618 ^^^^^^^^^^^^^^^^^^^^ 24 Nov 12:21:42.618 return self._apply(convert) 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1383, in to 24 Nov 12:21:42.618 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 24 Nov 12:21:42.618 return super().to(*args, **kwargs) 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/transformers/modeling_utils.py", line 3761, in to 24 Nov 12:21:42.618 pipe.text_encoder.to(torch.bfloat16) 24 Nov 12:21:42.618 File "/app/serve.py", line 66, in load_pipeline 24 Nov 12:21:42.618 ^^^^^^^^^^^^^^^ 24 Nov 12:21:42.618 _pipe = load_pipeline() 24 Nov 12:21:42.618 File "/app/serve.py", line 92, in lifespan 24 Nov 12:21:42.618 ^^^^^^^^^^^^^^^^^^^^^ 24 Nov 12:21:42.618 return await anext(self.gen) 24 Nov 12:21:42.618 File "/usr/lib/python3.12/contextlib.py", line 210, in aenter 24 Nov 12:21:42.618 async with self.lifespan_context(app) as maybe_state: 24 Nov 12:21:42.618 File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 638, in lifespan 24 Nov 12:21:42.618 ERROR: Traceback (most recent call last): 24 Nov 12:21:40.731 queued_call() 24 Nov 12:21:40.731 24 Nov 12:21:40.731 If you want to use the NVIDIA B300 SXM6 PC GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/ 24 Nov 12:21:40.731 The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_70 sm_75 sm_80 sm_86 sm_90. 24 Nov 12:21:40.731 NVIDIA B300 SXM6 PC with CUDA capability sm_103 is not compatible with the current PyTorch installation. 24 Nov 12:21:40.731 /usr/local/lib/python3.12/dist-packages/torch/cuda/init.py:540: UserWarning: 24 Nov 12:21:40.731 _warn_unsupported_code(d, device_cc, code_ccs) 24 Nov 12:21:40.731 For CUDA 13.2 use pip install torch==2.13.0 --index-url https://download.pytorch.org/whl/cu132 24 Nov 12:21:40.731 For CUDA 13.0 use pip install torch==2.13.0 --index-url https://download.pytorch.org/whl/cu130 24 Nov 12:21:40.731 For CUDA 12.9 use pip install torch==2.13.0 --index-url https://download.pytorch.org/whl/cu129 24 Nov 12:21:40.731 Your installed torch==2.13.0+cu126 does not include kernels for this GPU. Reinstall the same version against a CUDA build that does, e.g.: 24 Nov 12:21:40.731

  • 9.0 which supports hardware CC >=9.0,<10.0 24 Nov 12:21:40.731
  • 8.6 which supports hardware CC >=8.6,<9.0 except {8.7} 24 Nov 12:21:40.731
  • 8.0 which supports hardware CC >=8.0,<9.0 except {8.7} 24 Nov 12:21:40.731
  • 7.5 which supports hardware CC >=7.5,<8.0 24 Nov 12:21:40.731
  • 7.0 which supports hardware CC >=7.0,<8.0 except {7.2} 24 Nov 12:21:40.731
  • 6.0 which supports hardware CC >=6.0,<7.0 except {6.2} 24 Nov 12:21:40.731
  • 5.0 which supports hardware CC >=5.0,<6.0 except {5.3} 24 Nov 12:21:40.731 The following list shows the CCs this version of PyTorch was built for and the hardware CCs it supports: 24 Nov 12:21:40.731 /usr/local/lib/python3.12/dist-packages/torch/cuda/init.py:422: UserWarning: Found GPU0 NVIDIA B300 SXM6 PC which is of compute capability (CC) 10.3. 24 Nov 12:21:40.725 Loading pipeline components...: 100%|██████████| 5/5 [00:01<00:00, 3.03it/s] 24 Nov 12:21:39.561 Loading weights: 100%|██████████| 288/288 [00:00<00:00, 1028.75it/s][A 24 Nov 12:21:39.484 Loading weights: 24%|██▍ | 69/288 [00:00<00:00, 689.41it/s] 24 Nov 12:21:39.381 Loading weights: 0%| | 0/288 [00:00<?, ?it/s] 24 Nov 12:21:39.281 Loading pipeline components...: 0%| | 0/5 [00:00<?, ?it/s] Loading pipeline components...: 60%|██████ | 3/5 [00:00<00:00, 20.74it/s] 24 Nov 12:21:39.071 Fetching 14 files: 0%| | 0/14 [00:00<?, ?it/s] Fetching 14 files: 14%|█▍ | 2/14 [00:00<00:00, 13.95it/s] Fetching 14 files: 43%|████▎ | 6/14 [00:00<00:00, 25.52it/s] Fetching 14 files: 64%|██████▍ | 9/14 [00:00<00:00, 9.94it/s] Fetching 14 files: 79%|███████▊ | 11/14 [00:01<00:00, 4.68it/s] Fetching 14 files: 86%|████████▌ | 12/14 [00:19<00:00, 4.68it/s] Fetching 14 files: 93%|█████████▎| 13/14 [00:31<00:04, 4.52s/it] Fetching 14 files: 100%|██████████| 14/14 [00:40<00:00, 5.34s/it] Fetching 14 files: 100%|██████████| 14/14 [00:40<00:00, 2.88s/it] 24 Nov 12:20:58.548 Warning: You are sending unauthenticated requests to the HF Hub. Please set a HF_TOKEN to enable higher rate limits and faster downloads. 24 Nov 12:20:58.320 INFO: Waiting for application startup. 24 Nov 12:20:58.320 INFO: Started server process [1] 24 Nov 12:20:58.320 loading Efficient-Large-Model/Sana_1600M_1024px_diffusers variant='fp16' 24 Nov 12:20:49.729 Starting workload container 24 Nov 12:19:38.064 Downloading container image 24 Nov 12:19:26.755 Workload initialization started 24 Nov 12:17:20.685 Provisioning resources for the workload

Claude: That log shows the cause: the Endpoint is running on the wrong GPU for this container. Restarting it will fail the same way, so stop it now. A B300 is expensive and bills while it provisions.

What the log says:

  • Found GPU0 NVIDIA B300 SXM6 PC ... compute capability (CC) 10.3: the Endpoint got an NVIDIA B300, a newer Blackwell GPU.
  • Your installed torch==2.13.0+cu126 does not include kernels for this GPU and supports ... sm_80 sm_86 sm_90: the PyTorch in the Sana container image goes up to sm_90 (Hopper: H100/H200). It has no code built for the B300's sm_103.
  • The model downloads and loads fine. The first time it tries to put weights on the GPU (pipe.text_encoder.to(torch.bfloat16) in serve.py), CUDA fails with no kernel image is available for execution on the device. The app exits, and the Endpoint goes to ERROR.

That also explains your 24.5 seconds: about 20 seconds of 502s while the model loaded, then the crash, then the 404 once the pod was gone.

Fix: stop or delete this Endpoint and create a new one on a GPU the container supports. The course template uses an L40S, and the notebook has ENDPOINT_GPU = "L40S". Open the Sana template link again (https://console.nebius.com/serverless/endpoint/create?template=sana). Before clicking Create, check the GPU / platform field. If it shows B300 or B200, change it to L40S. H100 or H200 would also work but cost more. If your region doesn't offer an L40S, pick another region that does.

You can't change the GPU on this Endpoint by restarting it. As before, copy the new token before clicking Create. Then put the new BASE_URL and TOKEN in code/.env, restart the kernel, and run the notebook from the top.

Shannon: I have finished the assignment ``. Now I need to complete the homework. The homework entry form requires a submission URL. I will push this closed repo to a new repo on my own GitHub account. Please list the steps I will follow to create an appropriate fine grained personal access token, then the commands I will run in the terminal to push this modified repo to GitHub.

Claude: Nothing secret will go up. code/.env (your token), .venv/, runs/ and __pycache__/ are all ignored by the repo's .gitignore. The only change Git sees is your edited nb-first-generation-local.ipynb. The notebook has no token in it. One cell's output prints your old Endpoint's URL (https://port8000-y15…eu-north1…); that's harmless once the Endpoint is deleted.

Because runs/ is ignored, your generated images won't be pushed, but they're embedded in the notebook outputs. Right now origin points to DataTalksClub/production-ai-agents-for-media-generation, which you can't push to, so we'll add your repo as a second remote.

1. Create the empty repo (GitHub web)

  1. Go to https://github.com/new while signed in as spycebot.
  2. Repository name: e.g. production-ai-agents-for-media-generation.
  3. Choose Public, so the graders can open the submission URL.
  4. Leave README, .gitignore and license unticked. The repo must be empty, or the push will be rejected.
  5. Click Create repository.

2. Create the fine-grained token

  1. Go to Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token, or open https://github.com/settings/personal-access-tokens/new.
  2. Token name: e.g. push-media-gen-homework. Expiration: 7 days is plenty.
  3. Resource owner: spycebot.
  4. Repository access: Only select repositories, then choose the repo you just made.
  5. Permissions → Repository permissions:
    • Contents: Read and write. This is the only one needed to push.
    • Metadata: Read-only is added automatically.
    • Leave everything else at No access. You don't need Workflows, because you're not pushing changes under .github/workflows/.
  6. Click Generate token and copy it right away. Like the Endpoint token, it's shown only once.

3. Push from the terminal

Run these from the course repo folder. First, go there:

cd C:\Users\safetystation\Documents\production-ai-agents-for-media-generation

Stage and commit your completed notebook:

git add 01-consistent-media-generation-on-serverless-gpus/code/nb-first-generation-local.ipynb
git commit -m "Lesson 01 homework: first generation notebook with outputs"

Add your repo as a second remote. The original stays as origin, so you can still pull course updates:

git remote add mine https://github.com/spycebot/production-ai-agents-for-media-generation.git

Push main to your repo:

git push -u mine main

When Git asks you to sign in, Git Credential Manager may open a window. Choose Token (or "Personal access token") if offered and paste the PAT. If it asks for a username and password instead, use spycebot as the username and the PAT as the password.

4. Submission URL

After the push, use the link to the notebook itself:

https://github.com/spycebot/production-ai-agents-for-media-generation/blob/main/01-consistent-media-generation-on-serverless-gpus/code/nb-first-generation-local.ipynb

Open it in a private browser window first. That confirms it's public and that the outputs and images render.

A couple of side notes:

  • You'll see a LF will be replaced by CRLF warning. It's harmless.
  • After git push -u mine main, a plain git pull will pull from your repo, not the course. To get course updates later, run git pull origin main.

Shannon: PS C:\Users\safetystation\Documents\production-ai-agents-for-media-generation> git push -u mine main remote: Permission to spycebot/production-ai-agents-for-media-generation.git denied to spycebot. fatal: unable to access 'https://github.com/spycebot/production-ai-agents-for-media-generation.git/': The requested URL returned error: 403

I believe I need to run a login command

Claude: You don't need a separate login command. Git never asked you for anything: it reused a token it had already saved for github.com.

Your Git uses Git Credential Manager, and it already holds a saved login for https://github.com. That's probably the fine-grained token you use for the SNG repos, which only has access to those repos. Git sent that token as spycebot, and GitHub refused it for the new repo. That's the "Permission … denied to spycebot" 403. The new PAT was never used.

The simplest fix that doesn't break your SNG pushes: tell this repo only to look up credentials by the full repo URL. The saved github.com login then won't match, and Git will ask for one.

In the course repo folder:

git config credential.useHttpPath true
git push -u mine main

When it asks you to sign in, choose Token / Personal access token and paste the new PAT. If it asks for a username and password, use spycebot and the PAT. Git Credential Manager saves it for this repo's URL only, so your SNG repos keep using their existing token.

If it still returns 403 after you've pasted the new PAT, the token itself is the problem. On the token's page on GitHub, check two things:

  • Under Repository access, the new repo is listed.
  • Under permissions, Contents is Read and write, not Read-only.

You can edit an existing fine-grained token; you don't have to make a new one. Push again afterwards.

Shannon: PS C:\Users\safetystation\Documents\production-ai-agents-for-media-generation> git config credential.useHttpPath true PS C:\Users\safetystation\Documents\production-ai-agents-for-media-generation> git push -u mine main remote: Permission to spycebot/production-ai-agents-for-media-generation.git denied to spycebot. fatal: unable to access 'https://github.com/spycebot/production-ai-agents-for-media-generation.git/': The requested URL returned error: 403

It does not ask for the new PAT

Claude: The cause is a GitHub CLI setting, not a stored password. Your global ~/.gitconfig has this line, which gh auth setup-git added at some point:

credential.https://github.com.helper = !gh.exe auth git-credential

So for every github.com URL, Git asks the gh CLI for a token, and gh always hands over the token it's logged in with: your SNG-scoped github_pat_…. I confirmed that Git returns that token for the new repo's URL. That's why useHttpPath changed nothing and you never got a prompt.

Fix for this repo only (your SNG repos keep using gh as they do now). Run these in the course repo folder. The --% matters: PowerShell 5.1 otherwise drops the empty "", which is what clears the inherited helpers.

git config --% credential.https://github.com.helper ""
git config --add credential.https://github.com.helper manager
git push -u mine main

This time Git Credential Manager should pop up a sign-in. Choose Token, paste the new PAT, and it's saved for this repo's URL only.

Avoid running gh auth login with the new PAT. That swaps the token gh uses everywhere, so your SNG repos would start failing.

Shannon: https://github.com/spycebot/production-ai-agents-for-media-generation/blob/main/01-consistent-media-generation-on-serverless-gpus/code/nb-first-generation-local.ipynb It is interesting to use a cloud GPU to generate media assets. However, in the Practice** section, I am unhappy with the depiction of the girl, because her eyes do not align (we would say that she is cross-eyed (eyes pointing in) or wall-eyed (eyes pointing out)). If it were my job to produce these images, how would I correct this issue with the eyes so that the images were more appealing?

Claude: Congratulations on getting the homework submitted. I looked at your Practice cells, and a few things in the setup make wandering eyes likely. Here's how I'd fix them, cheapest first.

Why it happens here

  • The face is tiny. You ask for 512x512 and a full figure: girl, dress, hat, cake, plus snow, a laptop or decorations. The face may only be about 50 pixels across, so each eye is a handful of pixels. Diffusion models handle small details badly, and eyes are where people notice it most. The model you're using, Sana_1600M_1024px, was also trained for 1024×1024, so 512 is below its native size.
  • The style line asks for loose, hand-drawn faces. "Ink and pigment illustration in the style of …" pulls toward sketchy picture-book drawing, where eyes are often just a pair of quick marks. Naming a specific published book also runs against the course's rule to keep prompts free of known works. Describing the style's traits works better anyway.

Fixes at generation time (all available in generate_image / ImageGenerator)

  1. Generate at 1024×1024 (size="1024x1024"). This is the biggest single improvement for faces.
  2. Frame the face larger. Ask for a "medium shot, waist up, face clearly visible, looking at the viewer" so the face takes up more of the image.
  3. Describe the eyes outright: e.g. "symmetrical friendly face, both eyes looking at the viewer". In a picture-book style, "simple round dot eyes" avoids the problem almost entirely.
  4. Add a negative prompt. ImageGenerator.generate_image accepts negative_prompt= (it's "" by default in models.py). Try "cross-eyed, misaligned eyes, asymmetrical eyes, deformed face". It helps, but it won't guarantee a fix.
  5. Slightly more steps. The default is num_inference_steps=20; 28–30 often sharpens fine detail. You can leave guidance_scale at 4.5.
  6. Generate several seeds and pick the best. Each image takes about a second on the Endpoint, so for a real job you'd make 8–16 variants per scene and keep the good ones. That's normal practice, and you record the winning seed so you can reproduce it.

Fixing an image you otherwise like (the professional route)

  • Edit just the face. Use an image-editing model with an instruction like "correct her eyes so both look at the viewer; keep everything else unchanged". This course's own landscape lesson lists Qwen-Image-Edit-2511 for this, and it has a Nebius template, so you'll meet it later in the module.
  • Inpaint the eyes: mask only the eye area and regenerate it, leaving the rest of the image untouched.
  • Run a "face detailer" pass: crop the face, regenerate that crop at high resolution, then paste it back. This is the standard fix for small faces in full-body shots.

For your birthday-card images, I'd try 1024×1024, waist-up framing, "simple round dot eyes looking at the viewer" in the prompt, and a handful of seeds. That will probably fix it without any editing step.

Shannon: https://courses.datatalks.club/production-ai-agents-generative-media/homework/module1 Question 7 in he homework asks "What is your projected cost per asset at N = 1000, in USD?" How do I determine this. Was this something I should have read from the Nebius cloud endpoint before I deleted it?

Claude: You don't need anything more from the deleted Endpoint. At N = 1000, the times you could only have read there (startup and model load) change the answer by about a tenth of a cent per thousand assets.

How the course computes it (lesson 05 and the homework instructions):

Cost per asset = F / N + c

  • F (fixed, paid once per run) = (startup + model load seconds) × price per second
  • c (paid per asset) = median generation seconds × price per second

Your numbers

  • Q6, median generation time: 1.9 s. I pulled all 27 Generated in … s lines from your saved notebook. They range from 1.7 to 2.0 s, and the median is 1.9. These times are measured from your laptop, so they include network time and slightly overstate GPU time. The homework says any honest answer counts, so that's fine.
  • Price: Nebius doesn't charge separately for Endpoints; they're billed at Compute VM prices. Nebius's pricing docs list the L40S, available only in eu-north1 (your Endpoint's region), at $0.65 per GPU-hour preemptible and $1.35 on-demand. The Sana template is preemptible by default.
  • F: endpoint mode doesn't record startup or load (startup_s: null in your metrics.json). Your earlier B300 Endpoint's logs show about 4–4.5 minutes from "Provisioning" to the model loaded, so use about 260 s as an estimate.

Q7 at N = 1000, preemptible ($0.65/h = $0.000181/s):

  • c = 1.9 × 0.000181 ≈ $0.000343
  • F/N = 260 × 0.000181 / 1000 ≈ $0.000047
  • Total ≈ $0.0004 per asset

If your Endpoint was not preemptible ($1.35/h), it's about $0.0008.

Your fixed cost could be off by a minute either way and the answer would still round to $0.0004. That's the lesson's point: with large batches, cost per asset is almost entirely generation time × price.

If you want to confirm which rate you actually paid, Billing → Usage in the Nebius console still shows the deleted Endpoint's charges. The line item should say whether it was billed as preemptible.

Shannon: For the previous two courses, I did not make any FAQ contribution along with the homework. I would like to begin doing so now. How do I go about this? Do I make a modification to the repo?

Claude: No, you don't change the course repo. DataTalksClub keeps all its course FAQs in a separate repo, DataTalksClub/faq, and new entries are proposed through a GitHub issue form, not a pull request.

How to contribute (from that repo's CONTRIBUTING.md):

  1. Check the course FAQ first, so you don't duplicate an existing entry: https://datatalks.club/faq/production-ai-agents-generative-media.html
  2. Open the proposal form: https://github.com/DataTalksClub/faq/issues/new?template=faq-proposal.yml
  3. Pick the course (Production AI Agents for Generative Media), then write the question and your answer.
  4. A maintainer, or their automation, turns it into an entry and reviews it before it's published. You'll get a comment on the issue either way, including if it's already answered.

Pull requests are only for fixing an existing entry.

Their writing tips, in short:

  • Phrase the question the way a student would search for it, starting with How, What, Why or When.
  • Cover one problem per entry.
  • Give the fix first.
  • Make any code runnable as written.
  • Link to official sources instead of paraphrasing them.
  • If unclear course material caused the confusion, say so.

What to put in the homework form: neither the FAQ page nor the contribution guide says. The link to your proposal issue (https://github.com/DataTalksClub/faq/issues/…) is the natural thing to submit. If the form asks for something else, the course Slack channel #course-ai-mediagen can confirm.

You already have good material from today, each a real problem another student could hit:

  • "Why does my Sana Endpoint go to ERROR with 'no kernel image is available for execution on the device'?" The Endpoint landed on a B300, and the container's PyTorch (cu126) only supports up to sm_90. Pick an L40S (or H100/H200) in the form. This is probably the most valuable one.
  • "Why does wait_ready fail with HTTPError 404?" unknown_tunnel means the Endpoint isn't running (stopped, crashed or deleted), or the URL is out of date. Check its status and logs in the console.
  • "Is the tenantuseraccount-… string in the console my Endpoint token?" No, it's your account ID. The token is shown once in the create form.
  • "Why does the first notebook cell hang in VS Code on Windows?" No kernel starts with system Python 3.14. Run uv sync --extra notebooks and select .venv.

hall I draft a FAQ entry from one of today's problems for you to paste in?

New FAQ entries for DataTalksClub courses go through a GitHub issue form on the DataTalksClub/faq repo. You don't change the course repo or open a pull request. Nothing has been drafted or submitted yet.

  • Yes, draft one
  • Not now

Shannon: Yes, draft one

Claude: Here's a draft for the B300 problem, the one most likely to help other students. Check the course FAQ first in case someone has already posted it. Copy the two fields into the form, and pick Production AI Agents for Generative Media as the course.

* * *

Question

Why does my Sana Endpoint go to ERROR with "CUDA error: no kernel image is available for execution on the device"?

Answer

The Endpoint is running on a GPU that the container's PyTorch build doesn't support. Recreate it on an L40S (or H100/H200).

In the Endpoint's **Logs** you'll see the model download and load, then a crash when the weights are moved to the GPU:

```
Found GPU0 NVIDIA B300 SXM6 PC which is of compute capability (CC) 10.3.
Your installed torch==2.13.0+cu126 does not include kernels for this GPU.
...
torch.AcceleratorError: CUDA error: no kernel image is available for execution on the device
ERROR: Application startup failed. Exiting.
```

The Sana container's PyTorch is built for CUDA 12.6, which supports GPUs up to compute capability 9.0 (`sm_90`: Hopper, e.g. H100/H200). Blackwell GPUs such as the B200 and B300 (`sm_100`/`sm_103`) need a newer CUDA build, so the server exits and the Endpoint goes to `ERROR`.

Restarting won't help, because it starts on the same GPU. To fix it:

1. Stop or delete the failed Endpoint. A B300 is expensive and bills while it provisions.
2. Create a new Endpoint from the [Sana template](https://console.nebius.com/serverless/endpoint/create?template=sana) and, before clicking **Create**, check the GPU/platform field is **L40S**, the GPU the lesson uses. H100 or H200 also work but cost more.
3. Copy the new token before clicking **Create**, then delete `BASE_URL` and `TOKEN` from `code/.env`, restart the kernel, and run the notebook from the top.

In the notebook, `wait_ready` shows this as about 20 seconds of waiting followed by `HTTPError: HTTP Error 404: Not Found`. The 404 is because the crashed Endpoint's tunnel no longer exists.
* * *

A couple of things to check before you submit:

  • Step 2: I don't know whether the B300 was picked in the form or came from the template's default. If you remember, add one line saying which. Reviewers will find that useful, and if the template itself defaults to B300, that's worth flagging as a course-material issue.
  • The log lines are copied from your logs, trimmed to the key ones. Your Endpoint URL and token don't appear anywhere in the draft.

I can draft any of the other three the same way.

Shannon: Please draft an answer to "Why does the first notebook cell hang in VS Code on Windows?" based on the details in this session that we had today.

Claude: Here's the draft. Pick Production AI Agents for Generative Media as the course and paste the two fields in.

* * *

Question

Why does the first cell of the lesson notebook hang in VS Code on Windows?

Answer

The cell isn't hanging. VS Code is waiting for a Jupyter kernel that can't start. Create the course's own environment with `uv` and select it as the kernel.

Even a cell as simple as this one keeps spinning and never gets an execution number:

```python
import sys
from pathlib import Path
```

Usually the notebook has picked a plain "Python 3" kernel, which VS Code points at your system Python. If that Python has no `ipykernel` installed, the kernel never starts. The course repository also needs **Python 3.12 or 3.13** (`requires-python = ">=3.12,<3.14"` in `pyproject.toml`). So if your only Python is 3.14, installing `ipykernel` into it isn't the fix either.

To fix it:

1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) (PowerShell):

   ```powershell
   powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
   ```

2. Open a new terminal in the repository root and create the environment. uv downloads a compatible Python by itself, and the `notebooks` extra includes `ipykernel`:

   ```powershell
   uv sync --extra notebooks
   ```

   You don't need the `gpu` extra on your laptop. The local notebook only calls the remote Endpoint.

3. In VS Code, click the kernel picker (top right of the notebook) → **Select Another Kernel** → **Python Environments**, and choose `.venv\Scripts\python.exe` in the repository.

4. Restart the kernel and run the notebook from the top. The first cell should finish almost at once.

If it still spins, open **View → Output** and choose **Jupyter** in the dropdown to see why the kernel failed to start.

The cell that calls `setup_endpoint()` can also look stuck. On the first run it asks for the Endpoint URL and token in an input box at the **top of the VS Code window**, not in the notebook. If the box loses focus it can disappear: interrupt the kernel and run the cell again.
* * *

A few notes:

  • I left out details specific to your machine: your paths, and the 3.14 install under AppData\Local\Python\pythoncore-3.14-64. The answer only mentions 3.14 as the version that doesn't work.
  • The last paragraph about the input box is a separate problem. If you'd rather keep strictly to one problem per entry, as their guide asks, cut it and submit it as its own FAQ entry later.
  • The uv install command is the one from uv's official docs.
ImpressumContactTermsPrivacy