GithubHelp home page GithubHelp logo

amypad / cuvec Goto Github PK

View Code? Open in Web Editor NEW
79.0 4.0 2.0 730 KB

Unifying Python/C++/CUDA memory: Python buffered array ↔️ `std::vector` ↔️ CUDA managed memory

Home Page: https://amypad.github.io/CuVec/

License: Other

CMake 13.90% Python 42.66% Cuda 37.77% SWIG 3.38% Makefile 2.30%
c cuda python array vector buffer cpython cpython-extensions cpython-api cpp

cuvec's People

Contributors

0x2b3bfa0 avatar casperdcl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cuvec's Issues

Installation fails in WSL environment

Unsuccessful attempt to install this package on a WSL2 Ubuntu system as a (AmyPET) dependency. Some required libraries are missing, perhaps?

System details:

(amypet_dev) user@host:/.../AmyPET$ uname -r
5.10.60.1-microsoft-standard-WSL2
(amypet_dev) user@host:/.../AmyPET$ python -V
Python 3.7.13
(amypet_dev) user@host:/.../AmyPET$ pip -V
pip 22.0.4 from /home/user/venvs/amypet_dev/lib/python3.7/site-packages/pip (python 3.7)

pip error trace:

(amypet_dev) user@host:/.../AmyPET$ pip install cuvec
Collecting cuvec
  Using cached cuvec-2.11.1.tar.gz (37 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: cuvec
  Building wheel for cuvec (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cuvec (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [83 lines of output]
      WARNING:cuvec.setup:Import or CUDA device detection error:
      NVML Shared Library Not Found
      Not searching for unused variables given on the command line.
      -- The C compiler identification is GNU 7.5.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- The CXX compiler identification is GNU 7.5.0
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /tmp/pip-install-ty00gks4/cuvec_d337dca4039c4731a10fcf56a873fa80/_cmake_test_compile/build
      -- The C compiler identification is GNU 7.5.0
      -- The CXX compiler identification is GNU 7.5.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      CMake Error at /tmp/pip-build-env-4csnmbpo/overlay/lib/python3.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
        Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES
        Development Development.Module Development.Embed) (found version "3.7.13")
      Call Stack (most recent call first):
        /tmp/pip-build-env-4csnmbpo/overlay/lib/python3.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
        /tmp/pip-build-env-4csnmbpo/overlay/lib/python3.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPython/Support.cmake:3166 (find_package_handle_standard_args)
        /tmp/pip-build-env-4csnmbpo/overlay/lib/python3.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPython3.cmake:490 (include)
        CMakeLists.txt:12 (find_package)
...
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cuvec
Failed to build cuvec
ERROR: Could not build wheels for cuvec, which is required to install pyproject.toml-based projects

separate cpu/cuda modules

current

  • cuvec.cuvec: at compile time, use cudaMallocManaged/cudaFree if available, otherwise use malloc/free
    • at runtime, people with NVIDIA GPUs are forced to allocate memory on their device

proposed

  • cuvec.cuvec_cpu: uses malloc/free
  • cuvec.cuvec_cuda: if available, use cudaMallocManaged/cudaFree, otherwise ImportError
  • cuvec.cuvec: point to one of the above

SWIG support

SWIG provides std_vector.i. CuVec could provide similar (e.g. cuvec.i) to support any language (not just Python) supported by SWIG

build: conda-forge

potential alternative to #27:

conda-forge (CUDA and non-CUDA) recipe for the parallelproj projectors (libparallelproj) [...]: https://github.com/conda-forge/parallelproj-feedstock

The main things I learned/had to reali[s]e where:

  1. All your dependencies need to be on conda-forge
  2. For handling cuda in the meta.yaml, there is # [cuda_compiler_version != "None"] "decorator" to describe cuda/non-cuda specific things
  3. at runtime you need the virtual __cuda conda-forge package as dependency which helps the package manager to figure out which package version needs to be / can be installed on systems with and without cuda https://github.com/conda-forge/parallelproj-feedstock/blob/af55c92209af12cfad72f03078c24d0f0412045b/recipe/meta.yaml#L47
  4. for the builds there are no physical GPUs available meaning that all tests requiring GPUs need to be skipped (this might change in the future)
  5. In the build scripts, you can test the ${cuda_compiler_version} to trigger CUDA / non-cuda specific things https://github.com/conda-forge/parallelproj-feedstock/blob/af55c92209af12cfad72f03078c24d0f0412045b/recipe/build-parallelproj.sh#L7

I think the recipe for libparallelproj is a good starting point. Note that libparallelproj in the meta.yaml I build two packages (libparallelproj with CUDA and non-CUDA version, and also parallelproj which is a minimal python interface to the libs).

The conda-forge team on gitter.im also helped me a lot in the beginning.

@gschramm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.