You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/src/puzzle_09/first_case.md
+8-24Lines changed: 8 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ This puzzle presents a crashing GPU program where your task is to identify the i
7
7
**Prerequisites**: Complete [Mojo GPU Debugging Essentials](./essentials.md) to understand CUDA-GDB setup and basic debugging commands. Make sure you've run:
8
8
9
9
```bash
10
-
pixi run setup-cuda-gdb
10
+
pixi run -e nvidia setup-cuda-gdb
11
11
```
12
12
13
13
This auto-detects your CUDA installation and sets up the necessary links for GPU debugging.
@@ -35,31 +35,15 @@ To experience the bug firsthand, run the following command in your terminal (`pi
35
35
pixi run -e nvidia p09 --first-case
36
36
```
37
37
38
-
You'll see output like when the program crashes with this error:
38
+
You'll see output like this when the program crashes:
39
39
40
40
```txt
41
-
CUDA call failed: CUDA_ERROR_ILLEGAL_ADDRESS (an illegal memory access was encountered)
42
-
[24326:24326:20250801,180816.333593:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
43
-
[24326:24326:20250801,180816.333653:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
44
-
Please submit a bug report to https://github.com/modular/modular/issues and include the crash backtrace along with all the relevant source codes.
45
-
Stack dump:
46
-
0. Program arguments: /home/ubuntu/workspace/mojo-gpu-puzzles/.pixi/envs/default/bin/mojo problems/p09/p09.mojo
47
-
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
48
-
0 mojo 0x0000653a338d3d2b
49
-
1 mojo 0x0000653a338d158a
50
-
2 mojo 0x0000653a338d48d7
51
-
3 libc.so.6 0x00007cbc08442520
52
-
4 libc.so.6 0x00007cbc0851e88d syscall + 29
53
-
5 libAsyncRTMojoBindings.so 0x00007cbc0ab68653
54
-
6 libc.so.6 0x00007cbc08442520
55
-
7 libc.so.6 0x00007cbc084969fc pthread_kill + 300
56
-
8 libc.so.6 0x00007cbc08442476 raise + 22
57
-
9 libc.so.6 0x00007cbc084287f3 abort + 211
58
-
10 libAsyncRTMojoBindings.so 0x00007cbc097c7c7b
59
-
11 libAsyncRTMojoBindings.so 0x00007cbc097c7c9e
60
-
12 (error) 0x00007cbb5c00600f
61
-
mojo crashed!
62
-
Please file a bug report.
41
+
First Case: Try to identify what's wrong without looking at the code!
42
+
43
+
stack trace was not collected. Enable stack trace collection with environment variable `MOJO_ENABLE_STACK_TRACE_ON_ERROR`
44
+
Unhandled exception caught during execution: At open-source/max/mojo/stdlib/stdlib/gpu/host/device_context.mojo:2082:17: CUDA call failed: CUDA_ERROR_INVALID_IMAGE (device kernel image is invalid)
45
+
To get more accurate error information, set MODULAR_DEVICE_CONTEXT_SYNC_MODE=true.
46
+
/home/ubuntu/workspace/mojo-gpu-puzzles/.pixi/envs/nvidia/bin/mojo: error: execution exited with a non-zero result: 1
Copy file name to clipboardExpand all lines: book/src/puzzle_09/second_case.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,10 @@ Building on your [crash debugging skills from the First Case](./first_case.md),
11
11
12
12
This intermediate-level debugging challenge covers investigating **algorithmic errors** using `LayoutTensor` operations, where the program runs successfully but produces wrong output - a much more common (and trickier) real-world debugging scenario.
13
13
14
-
**Prerequisites**: Complete [Mojo GPU Debugging Essentials](./essentials.md) and [Detective Work: First Case](./first_case.md) to understand CUDA-GDB workflow and systematic debugging techniques. Make sure you've run `pixi run setup-cuda-gdb` or similar symlink is available
14
+
**Prerequisites**: Complete [Mojo GPU Debugging Essentials](./essentials.md) and [Detective Work: First Case](./first_case.md) to understand CUDA-GDB workflow and systematic debugging techniques. Make sure you run the setup:
Each position should sum its neighbors: [left + center + right]
52
-
Actual result: HostBuffer([0.0, 1.0, 3.0, 5.0])
53
-
Expected: [1.0, 3.0, 6.0, 5.0]
54
-
❌ Test FAILED - Sliding window sums are incorrect!
55
-
Check the window indexing logic...
51
+
stack trace was not collected. Enable stack trace collection with environment variable `MOJO_ENABLE_STACK_TRACE_ON_ERROR`
52
+
Unhandled exception caught during execution: At open-source/max/mojo/stdlib/stdlib/gpu/host/device_context.mojo:2082:17: CUDA call failed: CUDA_ERROR_INVALID_IMAGE (device kernel image is invalid)
53
+
To get more accurate error information, set MODULAR_DEVICE_CONTEXT_SYNC_MODE=true.
54
+
/home/ubuntu/workspace/mojo-gpu-puzzles/.pixi/envs/nvidia/bin/mojo: error: execution exited with a non-zero result: 1
56
55
```
57
56
58
57
## Your task: detective work
@@ -69,7 +68,7 @@ Check the window indexing logic...
69
68
Start with:
70
69
71
70
```bash
72
-
pixi run mojo debug --cuda-gdb --break-on-launch problems/p09/p09.mojo --second-case
71
+
pixi run -e nvidia mojo debug --cuda-gdb --break-on-launch problems/p09/p09.mojo --second-case
pixi run mojo debug --cuda-gdb --break-on-launch problems/p09/p09.mojo --second-case
118
+
pixi run -e nvidia mojo debug --cuda-gdb --break-on-launch problems/p09/p09.mojo --second-case
120
119
```
121
120
122
121
#### Step 2: analyze the symptoms first
@@ -360,7 +359,7 @@ for offset in range(ITER): # ← Only 2 iterations: [0, 1]
360
359
- Focus on the algorithm logic rather than trying to inspect tensor contents
361
360
- Use systematic reasoning to trace what each thread should vs actually accesses
362
361
363
-
**💡 Key Insight**: This type of off-by-one loop bug is extremely common in GPU programming. The systematic approach you learned here - combining limited debugger info with mathematical analysis and pattern recognition - is exactly how professional GPU developers debug when tools have limitations.
362
+
**Key Insight**: This type of off-by-one loop bug is extremely common in GPU programming. The systematic approach you learned here - combining limited debugger info with mathematical analysis and pattern recognition - is exactly how professional GPU developers debug when tools have limitations.
This advanced-level debugging challenge teaches you to investigate **thread coordination failures** using shared memory, LayoutTensor operations, and barrier synchronization - combining all the systematic investigation skills from the previous cases.
13
13
14
-
**Prerequisites**: Complete [Mojo GPU Debugging Essentials](./essentials.md), [Detective Work: First Case](./first_case.md), and [Detective Work: Second Case](./second_case.md) to understand CUDA-GDB workflow, variable inspection limitations, and systematic debugging approaches. Make sure you've run `pixi run setup-cuda-gdb` or similar symlink is available
14
+
**Prerequisites**: Complete [Mojo GPU Debugging Essentials](./essentials.md), [Detective Work: First Case](./first_case.md), and [Detective Work: Second Case](./second_case.md) to understand CUDA-GDB workflow, variable inspection limitations, and systematic debugging approaches. Make sure you run the setup:
0 commit comments