Skip to content

Commit

Permalink
Addressed memory leak on CUDA devices (#108)
Browse files Browse the repository at this point in the history
* Addressed memory leak on CUDA devices
* Removed gpg check for cibuild
* Updated cibuildwheels to 2.19.0
  • Loading branch information
Jegp committed Jun 15, 2024
1 parent c336426 commit 30dd6c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
- if: ${{ env.ACT }}
run: pip install pipx
- name: Build wheels
uses: pypa/cibuildwheel@v2.14.1
uses: pypa/cibuildwheel@v2.19.0
env:
CIBW_BUILD_VERBOSITY: 2
CIBW_BUILD: "cp3{8,9,10}*"
CIBW_BUILD: "cp3{8,9,10,11}*"
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: x86_64
# Note: We need 2_28 because libcaer requires recent linux headers
CIBW_BUILD_FRONTEND: "pip"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BEFORE_BUILD: "rm -rf {project}/_skbuild"
CIBW_BEFORE_ALL_LINUX: 'yum install -y lz4-devel libgusb-devel SDL2-devel'
CIBW_BEFORE_ALL_LINUX: 'yum install -y lz4-devel libgusb-devel SDL2-devel --nogpgcheck'
CIBW_REPAIR_WHEEL_COMMAND: 'source .github/deps/fix_path.sh && auditwheel repair -w {dest_dir} {wheel}'

- uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you need to specify a different C++ compiler, be sure to also specify it for
AEStream can read from [Inivation](https://gitlab.com/inivation/dv/libcaer/) or [Prophesee](https://github.com/prophesee-ai/openeb/) event cameras, *given that the drivers are installed*.
**Please make sure the drivers are installed before installing aestream** (step 1 below).

1. Follow the instructions at https://gitlab.com/inivation/dv/libcaer/ to install the Inivation drivers and/or https://github.com/prophesee-ai/openeb/ to install the Prophesee drivers
1. Follow the instructions at [Inivation libcaer](https://gitlab.com/inivation/dv/libcaer/) to install the Inivation drivers and/or [Prophesee Openeb](https://github.com/prophesee-ai/openeb/) to install the Prophesee drivers
2. Install AEStream with pip: `pip install aestream --no-binary aestream -v`
* The `--no-binary` flag forces pip to recompile aestream for your system, which will detect the event camera drivers, if present.
* The `-v` flag enables verbose output, which will show you if the drivers were detected
Expand Down Expand Up @@ -66,7 +66,7 @@ To avoid this, we recomment using `--no-build-isolation` in the pip install, but
git clone https://github.com/aestream/aestream
cd aestream
# Install build dependencies
pip install scikit-build-core setuptools_scm pathspec
pip install scikit-build-core setuptools_scm pathspec nanobind
# Build aestream, but without build isolation
# Any future compilation will *only* compile the files you changed
pip install --no-build-isolation .
Expand Down
14 changes: 12 additions & 2 deletions src/python/tensor_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,18 @@ inline tensor_type BufferPointer::to_tensor_type() {
float *ptr = data.release();
int32_t device_type =
device == "cuda" ? nb::device::cuda::value : nb::device::cpu::value;
return tensor_type(ptr, 2, s, nb::handle(), /* owner */
nullptr, /* strides */
nb::capsule owner;
#ifdef USE_CUDA
if (device == "cuda") {
owner = nb::capsule(ptr, [](void *p) noexcept { free_memory_cuda((float *)p); });
} else {
#endif
owner = nb::capsule(ptr, [](void *p) noexcept { delete[] (float *) p; });
#ifdef USE_CUDA
}
#endif
return tensor_type(ptr, 2, s, owner, /* owner */
nullptr, /* strides */
nanobind::dtype<float>(), device_type);
}

Expand Down

0 comments on commit 30dd6c9

Please sign in to comment.