JuliaGPU / JuliaGPU/CUDA.jl

Lazy initialization doesn't trigger with all API calls

Open
#2,196 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Julia
Stars
1.4k
Forks
281
Avg merge
1d 7h
Merged PRs (30d)
30

Description

We only lazily initialize when initializing the task-local state, not when e.g. calling cuDeviceGetCount. That can result in bad error reporting:

julia> using CUDA
julia> devices()
Error showing value of type CUDA.DeviceIterator:
ERROR: UndefVarError: `libcuda` not defined
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/CUDA/YIj5X/lib/cudadrv/libcuda.jl:3090 [inlined]
  [2] #151
    @ ~/.julia/packages/CUDA/YIj5X/lib/utils/call.jl:27 [inlined]
  [3] check(f::CUDA.var"#151#152"{Base.RefValue{Int32}})
    @ CUDA ~/.julia/packages/CUDA/YIj5X/lib/cudadrv/libcuda.jl:32
  [4] cuDeviceGetCount(count::Base.RefValue{Int32})
    @ CUDA ~/.julia/packages/CUDA/YIj5X/lib/utils/call.jl:26
  [5] ndevices
    @ ~/.julia/packages/CUDA/YIj5X/lib/cudadrv/devices.jl:159 [inlined]
  [6] length
    @ ~/.julia/packages/CUDA/YIj5X/lib/cudadrv/devices.jl:143 [inlined]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with devices(), then inspect lib/cudadrv/libcuda.jl around line 3090 and lib/utils/call.jl:27, tracing the call from devices.jl:159 through ndevices and cuDeviceGetCount. Done means API calls trigger the required lazy initialization and report a proper CUDA error instead of UndefVarError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.