Skip to content

Overflow in randn using CUDA.jl's native RNG #1464

@danielwe

Description

@danielwe

Describe the bug

The native CUDA.jl rng regularly produces Infs when sampling standard normal Float32s. This is not expected: for practical purposes, the standard normal distribution has zero measure near floatmax(Float32), and neither CURAND's rng nor the default CPU rng have similar behavior.

To reproduce

The Minimal Working Example (MWE) for this bug:

using CUDA
using Random

println(maximum(randn(CUDA.default_rng(), Float32, 2^26)))         # Likely Inf
println(maximum(randn(CUDA.CURAND.default_rng(), Float32, 2^26)))  # Likely in (5.3, 6.1)
println(maximum(randn(Random.default_rng(), Float32, 2^26)))       # Likely in (5.3, 6.1)
Manifest.toml

CUDA v3.8.5
GPUArrays v8.3.2
GPUCompiler v0.13.14
LLVM v4.9.1

Expected behavior

No overflow, like with CUDA.CURAND.default_rng() and Random.default_rng().

Version info

Details on Julia:

Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) Platinum 8280 CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, cascadelake)

Details on CUDA:

CUDA toolkit 11.6, artifact installation
NVIDIA driver 465.19.1, for CUDA 11.3
CUDA driver 11.3

Libraries: 
- CUBLAS: 11.8.1
- CURAND: 10.2.9
- CUFFT: 10.7.0
- CUSOLVER: 11.3.2
- CUSPARSE: 11.7.1
- CUPTI: 16.0.0
- NVML: 11.0.0+465.19.1
- CUDNN: 8.30.2 (for CUDA 11.5.0)
- CUTENSOR: 1.4.0 (for CUDA 11.5.0)

Toolchain:
- Julia: 1.7.2
- LLVM: 12.0.1
- PTX ISA support: 3.2, 4.0, 4.1, 4.2, 4.3, 5.0, 6.0, 6.1, 6.3, 6.4, 6.5, 7.0
- Device capability support: sm_35, sm_37, sm_50, sm_52, sm_53, sm_60, sm_61, sm_62, sm_70, sm_72, sm_75, sm_80

2 devices:
  0: NVIDIA A100-PCIE-40GB (sm_80, 35.178 GiB / 39.586 GiB available)
  1: NVIDIA A100-PCIE-40GB (sm_80, 26.063 GiB / 39.586 GiB available)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions