     [ enumerate-cuda-devices ] dip '[ <launcher> _ with-cuda ] each ; inline
 
 : cuda-device-properties ( n -- properties )
-    init-cuda
     [ CUdevprop <c-object> ] dip
     [ cuDeviceGetProperties cuda-error ] 2keep drop
     CUdevprop memory>struct ;

    enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ;

: cuda-device-name ( n -- string )
    init-cuda
    [ 256 [ <byte-array> ] keep ] dip
    [ cuDeviceGetName cuda-error ]
    [ 2drop utf8 alien>string ] 3bi ;

: cuda-device-capability ( n -- pair )
    init-cuda
    [ int <c-object> int <c-object> ] dip
    [ cuDeviceComputeCapability cuda-error ]
    [ drop [ *int ] bi@ ] 3bi 2array ;

: cuda-device-memory ( n -- bytes )
    init-cuda
    [ uint <c-object> ] dip
    [ cuDeviceTotalMem cuda-error ]
    [ drop *uint ] 2bi ;

: cuda-device-attribute ( attribute n -- n )
    init-cuda
    [ int <c-object> ] 2dip
    [ cuDeviceGetAttribute cuda-error ]
    [ 2drop *int ] 3bi ;

: cuda-device. ( n -- )
    init-cuda
    {
        [ "Device: " write number>string print ]
        [ "Name: " write cuda-device-name print ]

IN: cuda.devices

: #cuda-devices ( -- n )
    int <c-object> [ cuDeviceGetCount cuda-error ] keep *int ;

: n>cuda-device ( n -- device )
    [ CUdevice <c-object> ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ;

: enumerate-cuda-devices ( -- devices )
