-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Describe the bug
I’m trying to use CuIterator and Flux.train!. Attempting to do so gives an error because train! tries to get the length of the CuIterator. So this:
iter = CuIterator(batch(i) for i in 1:10)
Flux.train!(loss, ps, iter, opt)
results in an error:
MethodError: no method matching length(::CuIterator{Base.Generator{UnitRange{Int64}, var"#17#18"}})
It appears that HasLength() is the default for Base.IteratorSize and CuIterator doesn’t specify it, so it uses the default.
To reproduce
The Minimal Working Example (MWE) for this bug:
data = CuIterator(x for x in .1:.1:1.)
itrsz = Base.IteratorSize(typeof(data))
n = (itrsz == Base.HasLength()) || (itrsz == Base.HasShape{1}()) ? length(data) : 0Manifest.toml
CUDA v3.12.0
Expected behavior
As suggested here, CuIterator should probably delegate HasLength and length to the wrapped iterator.
Version info
Details on Julia:
Julia Version 1.8.0
Commit 5544a0fab7 (2022-08-17 13:38 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 24 × AMD Ryzen 9 5900X 12-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
Threads: 24 on 24 virtual cores
Environment:
JULIA_EDITOR = code
Details on CUDA:
CUDA toolkit 11.7, artifact installation
NVIDIA driver 516.94.0, for CUDA 11.7
CUDA driver 11.7
Libraries:
- CUBLAS: 11.10.1
- CURAND: 10.2.10
- CUFFT: 10.7.1
- CUSOLVER: 11.3.5
- CUSPARSE: 11.7.3
- CUPTI: 17.0.0
- NVML: 11.0.0+516.94
- CUDNN: 8.30.2 (for CUDA 11.5.0)
- CUTENSOR: 1.4.0 (for CUDA 11.5.0)
Toolchain:
- Julia: 1.8.0
- LLVM: 13.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, 7.1, 7.2
- 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, sm_86
1 device:
0: NVIDIA GeForce RTX 2080 SUPER (sm_75, 6.783 GiB / 8.000 GiB available)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers