# Problem with Benchmark notebook

**URL:** <https://community.drivendata.org/t/problem-with-benchmark-notebook/6375>\
**Category:** STAC Overflow: Map Floodwater from Radar Imagery\
**Created:** [August 7, 2021, 10:08am UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375 "2021-08-07T10:08:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![suresh12](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@suresh12](https://community.drivendata.org/u/suresh12)\
**Post date:** [August 7, 2021, 10:08am UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/1 "2021-08-07T10:08:05Z")

</div>

Hi All,  
I was trying to the run the benchmark code in google colab, But I was run into problem . could please anyone help me to solve this.  
here my error.

```
   TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
```

---

<div class="post-metadata">

**Author:** ![bloodaxe](https://avatars.discourse-cdn.com/v4/letter/b/e68b1a/32.png) [@bloodaxe](https://community.drivendata.org/u/bloodaxe)\
**Post date:** [August 9, 2021, 6:03pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/2 "2021-08-09T18:03:17Z")

</div>

Tensors on CUDA cannot be converted to numpy directly. You need to manually move it to CPU first.  
The solution is exactly what is error description says: `x.detach().cpu().numpy()`.

---

<div class="post-metadata">

**Author:** ![polymathAB](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@polymathAB](https://community.drivendata.org/u/polymathAB)\
**Post date:** [August 13, 2021, 1:04pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/3 "2021-08-13T13:04:01Z")

</div>

what worked for me was changing true and preds to preds.to(‘cpu’).numpy() and true.to(‘cpu’).numpy()

---

<div class="post-metadata">

**Author:** ![suresh12](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@suresh12](https://community.drivendata.org/u/suresh12)\
**Post date:** [August 13, 2021, 3:15pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/4 "2021-08-13T15:15:49Z")

</div>

Thanks for the solution polymath.

---

<div class="post-metadata">

**Author:** ![Risha](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Risha](https://community.drivendata.org/u/Risha)\
**Post date:** [August 14, 2021, 11:27am UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/5 "2021-08-14T11:27:19Z")

</div>

@suresh12 were you able to solve it? I am still facing the issue after changing the line  
**return preds.detach().numpy().squeeze()** to **return preds.to(‘cpu’).detach().numpy().squeeze()**

Do we have to change somewhere else to? can you share the code snippet which you changed  
@polymathAB

---

<div class="post-metadata">

**Author:** ![polymathAB](https://avatars.discourse-cdn.com/v4/letter/p/a183cd/32.png) [@polymathAB](https://community.drivendata.org/u/polymathAB)\
**Post date:** [August 14, 2021, 12:04pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/6 "2021-08-14T12:04:46Z")

</div>

hi  
actually you have to use .to(‘cpu’) the first time preds and true are stored as numpy tensors which is in the following line:

> intersection = np.logical\_and(true, pred)  
> union = np.logical\_or(true, pred)

---

<div class="post-metadata">

**Author:** ![Risha](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Risha](https://community.drivendata.org/u/Risha)\
**Post date:** [August 14, 2021, 1:18pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/7 "2021-08-14T13:18:41Z")

</div>

> [@polymathAB](#):
>
> .to(‘cpu’)

Thanks for the help, solved.

---

<div class="post-metadata">

**Author:** ![isms](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.drivendata.org/isms/32/9_2.png) [@isms](https://community.drivendata.org/u/isms)\
**Post date:** [August 17, 2021, 11:13pm UTC](https://community.drivendata.org/t/problem-with-benchmark-notebook/6375/8 "2021-08-17T23:13:51Z")

</div>

Just FYI this has been fixed on the blog post in a recent round of edits. Thanks to @polymathAB for flagging.
