# Bad\_alloc error in import open3d

**URL:** <https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199>\
**Category:** Support\
**Created:** [October 18, 2021, 4:43am UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199 "2021-10-18T04:43:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 18, 2021, 4:43am UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/1 "2021-10-18T04:43:54Z")

</div>

Since r30305, we are getting this error after pip\_install(“open3d==0.10.0”). This is on ubuntu 20.04.

I believe Bad allocation is an out of memory error, so I assume real error is something else. Any suggestions on how to debug this will be great

```auto
import open3d
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/docker/MyData/Slicer-4.13.0-2021-10-14-linux-amd64/lib/Python/lib/python3.6/site-packages/open3d/ __init__.py", line 47, in <module>
    from open3d.open3d_pybind import camera
ImportError: std::bad_alloc

```

@agporto @smrolfe

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 18, 2021, 11:40am UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/2 "2021-10-18T11:40:41Z")

</div>

I’d suggest testing to see if the same thing happens in a non-slicer python. Also if you can build a open3d from source in debug mode you could single-step through and see what operation leads to the exception. Or on linux you can use `strace` to see what system calls happen before the exception.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 18, 2021, 4:25pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/3 "2021-10-18T16:25:15Z")

</div>

Can confirm that no such error is triggered on the system python when importing open3d. Although that’s version 3.8.10

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 5:58pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/4 "2021-10-27T17:58:40Z")

</div>

Anymore suggestions on this?  
This error breaks the functionality of ALPACA on linux platforms.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 6:02pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/5 "2021-10-27T18:02:48Z")

</div>

> [@pieper](#):
>
> you can use `strace` to see what system calls happen before the exception.

```auto
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(8, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0\337\0005\5\0\0\373\0\0\0\26\313\37\32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
select(21, [4 8 9 20], [], [], {tv_sec=21, tv_usec=917487}Python console user input: import open3d
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/maga/Downloads/Slicer/lib/Python/lib/python3.6/site-packages/open3d/ __init__.py", line 47, in <module>
    from open3d.open3d_pybind import camera
ImportError: std::bad_alloc
) = 1 (in [8], left {tv_sec=6, tv_usec=651769})
recvmsg(8, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\34\0\337\0005\5\0\09\1\0\0\270\6 \32\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 64
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)
recvmsg(8, {msg_namelen=0}, 0) = -1 EAGAIN (Resource temporarily unavailable)

```

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 6:19pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/6 "2021-10-27T18:19:58Z")

</div>

When you use an older Slicer preview version, it begins to work again? Fresh install of that older version.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 6:29pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/7 "2021-10-27T18:29:28Z")

</div>

I just tried with a fresh install of r30222 and pip\_install and import open3d worked fine.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 6:33pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/8 "2021-10-27T18:33:42Z")

</div>

What’s the date on these two revisions you’ve mentioned?

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 6:42pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/9 "2021-10-27T18:42:42Z")

</div>

And does the same error happen if you pip install in Slicer a newer release of Open3D? A new version will force a new download assuming you haven’t done it before and not use any cached wheel.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 6:45pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/10 "2021-10-27T18:45:21Z")

</div>

Yes. It does happen with new install.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 6:45pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/11 "2021-10-27T18:45:57Z")

</div>

> [@jamesobutler](#):
>
> What’s the date on these two revisions you’ve mentioned?

We have the problem since r30305. I am not sure how to go back to dates.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 6:47pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/12 "2021-10-27T18:47:56Z")

</div>

When you use the version that is r30305, does it not show the date next to the Slicer version in a window title bar or in Help-\>About Slicer?

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 6:51pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/13 "2021-10-27T18:51:34Z")

</div>

> [@jamesobutler](#):
>
> r30305

Sorry, I don’t have the r30305 installed anymore (too many transient versions of slicer confuses my workflows. I download, try and remove it). r30222 (working one) is from 9/18.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 6:52pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/14 "2021-10-27T18:52:43Z")

</div>

`slicer.app.repositoryRevision` should get the same type of information that I want. Just wanting to know the commit hashes so I can compare things that happened between working and not working.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 7:19pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/15 "2021-10-27T19:19:03Z")

</div>

Try the following 2 builds on Linux and see if it works on one or other. If it fails on both I can provide you with another set to test.

- r30297 - Slicer 4.13.0-2021-10-05  
[CDash - View Files](https://slicer.cdash.org/viewFiles.php?buildid=2425829)
- r30282 - Slicer 4.13.0-2021-10-03  
[CDash - View Files](https://slicer.cdash.org/viewFiles.php?buildid=2423240)

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 7:33pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/16 "2021-10-27T19:33:29Z")

</div>

Aren’t these prior to r30305? Those should work.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 7:34pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/17 "2021-10-27T19:34:11Z")

</div>

You tested every version earlier than r30305 to know that it was exactly this version where it broke?

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 7:37pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/18 "2021-10-27T19:37:49Z")

</div>

r30297 works as well.  
And yes I believe @agporto tested all versions up to r30305, but wasn’t able to find a specific change that might explain the crash.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [October 27, 2021, 7:41pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/19 "2021-10-27T19:41:48Z")

</div>

Ok, r30305 (Sicer 4.13.0-2021-10-07) [CDash - View Files](https://slicer.cdash.org/viewFiles.php?buildid=2428420), was the first release from the Slicer Linux Factory build machine that used GCC7 instead of GCC5. It was turned on first for this release as a test ([metroplex: Temporarily use gcc7 image for nightly · Slicer/DashboardScripts@c92c280 · GitHub](https://github.com/Slicer/DashboardScripts/commit/c92c2802b15d4b876d943a9fe3f8705af486512f)) and then was turned on permanently for all subsequent days. This switch from GCC7 from GCC5 was to fix a long running issue with SlicerJupyter not building correctly on Linux ([Linux: extension SlicerJupyter not available in 4.13 preview releases · Issue #59 · Slicer/SlicerJupyter · GitHub](https://github.com/Slicer/SlicerJupyter/issues/59#issuecomment-938611809)). Looking at the commits from October 7th and 6th on the Slicer there isn’t something obvious.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 27, 2021, 9:54pm UTC](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199/20 "2021-10-27T21:54:30Z")

</div>

I am building a py wheel for open3d, and will try to install that. But I am not sure how to do that with the slicer’s pip\_install. Can I point out to a file?

[Next page](https://discourse.slicer.org/t/bad-alloc-error-in-import-open3d/20199.md?page=2)
