Jutho / TensorOperations.jl

Julia package for tensor contractions and related operations
https://jutho.github.io/TensorOperations.jl/stable/
Other
443 stars 56 forks source link

Difficulties using GPU: @cutensor not defined #112

Closed DomCRose closed 2 years ago

DomCRose commented 2 years ago

Having issues getting things working on the GPU currently. Specifically, after importing TensorOperations and CUDA, @cutensor comes up as not defined, with an error on importing CUDA.

julia> using TensorOperations

julia> using CUDA
┌ Warning: Error requiring `CUDA` from `TensorOperations`
│   exception =
│    LoadError: UndefVarError: @workspace not defined
│    Stacktrace:
│      [1] include(mod::Module, _path::String)
│        @ Base .\Base.jl:386
│      [2] include(x::String)
│        @ TensorOperations C:\Users\domin\.julia\packages\TensorOperations\SVpOW\src\TensorOperations.jl:1
│      [3] macro expansion
│        @ C:\Users\domin\.julia\packages\Requires\7Ncym\src\Requires.jl:40 [inlined]
│      [4] top-level scope
│        @ C:\Users\domin\.julia\packages\TensorOperations\SVpOW\src\TensorOperations.jl:163
│      [5] eval
│        @ .\boot.jl:360 [inlined]
│      [6] eval
│        @ C:\Users\domin\.julia\packages\TensorOperations\SVpOW\src\TensorOperations.jl:1 [inlined]
│      [7] (::TensorOperations.var"#211#214")()
│        @ TensorOperations C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:99
│      [8] err(f::Any, listener::Module, modname::String)
│        @ Requires C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:47
│      [9] (::TensorOperations.var"#210#213")()
│        @ TensorOperations C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:98
│     [10] withpath(f::Any, path::String)
│        @ Requires C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:37
│     [11] (::TensorOperations.var"#209#212")()
│        @ TensorOperations C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:97
│     [12] #invokelatest#2
│        @ .\essentials.jl:708 [inlined]
│     [13] invokelatest
│        @ .\essentials.jl:706 [inlined]
│     [14] foreach(f::typeof(Base.invokelatest), itr::Vector{Function})
│        @ Base .\abstractarray.jl:2141
│     [15] loadpkg(pkg::Base.PkgId)
│        @ Requires C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:27
│     [16] #invokelatest#2
│        @ .\essentials.jl:708 [inlined]
│     [17] invokelatest
│        @ .\essentials.jl:706 [inlined]
│     [18] require(uuidkey::Base.PkgId)
│        @ Base .\loading.jl:942
│     [19] require(into::Module, mod::Symbol)
│        @ Base .\loading.jl:923
│     [20] eval
│        @ .\boot.jl:360 [inlined]
│     [21] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:139
│     [22] repl_backend_loop(backend::REPL.REPLBackend)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:200
│     [23] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:185
│     [24] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:317
│     [25] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\REPL\src\REPL.jl:305
│     [26] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
│        @ Base .\client.jl:387
│     [27] #invokelatest#2
│        @ .\essentials.jl:708 [inlined]
│     [28] invokelatest
│        @ .\essentials.jl:706 [inlined]
│     [29] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base .\client.jl:372
│     [30] exec_options(opts::Base.JLOptions)
│        @ Base .\client.jl:302
│     [31] _start()
│        @ Base .\client.jl:485
│    in expression starting at C:\Users\domin\.julia\packages\TensorOperations\SVpOW\src\implementation\cuarray.jl:2
└ @ Requires C:\Users\domin\.julia\packages\Requires\7Ncym\src\require.jl:49

julia> @cutensor
ERROR: LoadError: UndefVarError: @cutensor not defined
in expression starting at REPL[6]:1

This seems reminiscent of #107 and #109. I've seen this with CUDA 3.4.2 and 3.5, on TensorOperations 3.2.3. CUTENSOR is installed (see below for CUDA 3.4.2 case).

julia> CUDA.versioninfo()
CUDA toolkit 11.4.1, artifact installation
CUDA driver 11.4.0
NVIDIA driver 471.96.0

Libraries:
- CUBLAS: 11.5.4
- CURAND: 10.2.5
- CUFFT: 10.5.1
- CUSOLVER: 11.2.0
- CUSPARSE: 11.6.0
- CUPTI: 14.0.0
- NVML: 11.0.0+471.96
- CUDNN: 8.20.2 (for CUDA 11.4.0)
- CUTENSOR: 1.3.0 (for CUDA 11.2.0)

Toolchain:
- Julia: 1.6.3
- LLVM: 11.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

Any help would be much appreciated!

Jutho commented 2 years ago

Try using TensorOperations master; this has been fixed by @jfeist (thanks again). But I still have to tag a new version. Will try to do so later this week.

DomCRose commented 2 years ago

Ah right, didn't realise it wasn't in yet! Switching to master fixed it, thanks!