Skip to content

Commit 33ed684

Browse files
alexp616maleadt
andauthored
Update compute-sanitizer instructions (#2440)
[skip tests] Co-authored-by: Tim Besard <tim.besard@gmail.com>
1 parent aff5169 commit 33ed684

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

docs/src/development/debugging.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,27 @@ To disable all debug info emission, start Julia with the flag `-g0`.
9191

9292
## `compute-sanitizer`
9393

94-
To debug kernel issues like memory errors or race conditions, you can use CUDA's
95-
`compute-sanitizer` tool. Refer to the
96-
[manual](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html#using-compute-sanitizer)
97-
for more information.
94+
To debug kernel issues like memory errors or race conditions, you can use CUDA's `compute-sanitizer` tool. Refer to the [manual](https://docs.nvidia.com/compute-sanitizer/ComputeSanitizer/index.html#using-compute-sanitizer) for more information.
9895

99-
To facilitate using the compute sanitizer, CUDA.jl ships the tool as part of its artifacts.
100-
You can get the path to the tool using the following function:
96+
To use `compute-sanitizer`, you need to install the `CUDA_SDK_jll` package in your environment first.
10197

98+
To spawn a new Julia session under `compute-sanitizer`:
10299
```
103-
julia> using CUDA
104-
105-
julia> CUDA.compute_sanitizer()
106-
".julia/artifacts/7b09e1deca842d1e5467b6f7a8ec5a96d47ae0b4/bin/compute-sanitizer"
107-
108-
# including recommended options for use with Julia and CUDA.jl
109-
julia> CUDA.compute_sanitizer_cmd()
110-
`.julia/artifacts/7b09e1deca842d1e5467b6f7a8ec5a96d47ae0b4/bin/compute-sanitizer --tool memcheck --launch-timeout=0 --target-processes=all --report-api-errors=no`
111-
```
100+
julia> using CUDA_SDK_jll
112101
113-
To quickly spawn a new Julia session under `compute-sanitizer`, another helper function is
114-
provided:
102+
# Get location of compute_sanitizer executable
103+
julia> compute_sanitizer = joinpath(CUDA_SDK_jll.artifact_dir, "cuda/compute-sanitizer/compute-sanitizer")
104+
.julia/artifacts/feb6b469b6047f344fec54df2619d65f6b704bdb/cuda/compute-sanitizer/compute-sanitizer
115105
116-
```
117-
julia> CUDA.run_compute_sanitizer()
118-
Re-starting your active Julia session...
106+
# Recommended options for use with Julia and CUDA.jl
107+
julia> options = ["--launch-timeout=0", "--target-processes=all", "--report-api-errors=no"]
108+
3-element Vector{String}:
109+
"--launch-timeout=0"
110+
"--target-processes=all"
111+
"--report-api-errors=no"
119112
113+
# Run the executable with Julia
114+
julia> run(`$compute_sanitizer $options$(Base.julia_cmd())`)
120115
========= COMPUTE-SANITIZER
121116
julia> using CUDA
122117
@@ -126,9 +121,14 @@ julia> CuArray([1]) .+ 1
126121
127122
julia> exit()
128123
========= ERROR SUMMARY: 0 errors
129-
Process(`.julia/artifacts/7b09e1deca842d1e5467b6f7a8ec5a96d47ae0b4/bin/compute-sanitizer --tool memcheck --launch-timeout=0 --target-processes=all --report-api-errors=no julia -g1`, ProcessExited(0))
124+
Process(`.julia/artifacts/feb6b469b6047f344fec54df2619d65f6b704bdb/cuda/compute-sanitizer/compute-sanitizer --launch-timeout=0 --target-processes=all --report-api-errors=no julia`, ProcessExited(0))
130125
```
131126

127+
By default, `compute-sanitizer` launches the `memcheck` tool, which is great for dealing with
128+
memory issues. Other tools can be selected with the `--tool` argument, e.g., to find thread
129+
synchronization hazards use `--tool synccheck`, `racecheck` can be used to find shared memory
130+
data races, and `initcheck` is useful for spotting uses of uninitialized device memory.
131+
132132

133133
## `cuda-gdb`
134134

0 commit comments

Comments
 (0)