# MethodError: no method matching gemm!, It looks like |\>gpu cannot manage arrays resulting from view and reshape

**URL:** <https://discourse.julialang.org/t/methoderror-no-method-matching-gemm-it-looks-like-gpu-cannot-manage-arrays-resulting-from-view-and-reshape/96621>\
**Category:** GPU\
**Created:** [March 26, 2023, 8:47am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-gemm-it-looks-like-gpu-cannot-manage-arrays-resulting-from-view-and-reshape/96621 "2023-03-26T08:47:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Deflorio](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_deflorio/32/34365_2.png) [@Andrea\_Deflorio](https://discourse.julialang.org/u/Andrea_Deflorio)\
**Post date:** [March 26, 2023, 8:47am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-gemm-it-looks-like-gpu-cannot-manage-arrays-resulting-from-view-and-reshape/96621/1 "2023-03-26T08:47:55Z")

</div>

My julia version: 1.9 beta4

It looks like |\>gpu cannot manage arrays resulting from view and reshape. cu() can it!

When I run the code down, I get this error:  
Exception has occurred: CompositeException  
TaskFailedException

```
nested task error: TaskFailedException

    nested task error: MethodError: no method matching gemm!(::Val{false}, ::Val{false}, ::Int64, ::Int64, ::Int64, ::Float32, ::CuPtr{Float32}, ::CuPtr{Float32}, ::Float32, ::CuPtr{Float32})
    
    Closest candidates are:
      gemm!(::Val, ::Val, ::Int64, ::Int64, ::Int64, ::Float32, !Matched::Ptr{Float32}, !Matched::Ptr{Float32}, ::Float32, !Matched::Ptr{Float32})

```

etc.

Solution:  
replace: final\_arr\_gpu = (final\_arr)|\>gpu  
with: final\_arr\_gpu = cu(final\_arr)  
Alternative solution:  
before to send final\_arr to gpu, add line: final\_arr = collect(final\_arr)

Code running |\> in error:  
using Flux  
using CUDA

function testgpu()

# Set the parameters

# Generate Array with view and reshape

arr = rand(2, 3, 4)  
sub\_arr = view(arr, :, 1:2, 🙂  
final\_arr = reshape(sub\_arr, size(sub\_arr)…, 1)  
#final\_arr = collect(final\_arr)

@show typeof(final\_arr) # Array{Float32, 4}

# Define the model

model = Chain(  
Conv((2, 2), 4 =\> 16, relu),  
Flux.flatten,  
Dense(16, 32, relu),  
Dense(32, 1)  
) |\> gpu

# Move the data to the GPU

final\_arr\_gpu = (final\_arr)|\>gpu

# Run the model on the GPU

output = model(final\_arr\_gpu)
