Giter VIP home page Giter VIP logo

cuda-sys's Introduction

cuda-sys

name crate.io docs.rs CUDA
cuda-driver-sys Crate docs.rs 10.2
cuda-runtime-sys Crate docs.rs 10.2

Rust binding to CUDA Driver (libcuda.so) and Runtime (libcudart.so) APIs

This crate does NOT include CUDA itself. You need to install on your own.

CUDA Installation

  • You should install CUDA from the official installer.
  • or use nvidia/cuda container
    • This container does not add libcuda.so to dynamic link path. You need to add it to your ld path LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs or using ldconfig.

CUDA_LIBRARY_PATH environment variable

  • If you use system installer (e.g. apt, yum, pacman, and so on), the install path may be different.
  • $CUDA_LIBRARY_PATH (e.g. /opt/cuda/lib64) environment value adds paths to the list of library searching.
  • To verify that cuda-sys can find your CUDA installation, you can check that the CUDA_PATH environment variable has been set.

Q & A

Q. Program does not start (can be compiled) with following error message:

error while loading shared libraries: libcuda.so.1: cannot open shared object file: No such file or directory

A. Driver API (libcuda.so) is sometimes installed in a separate directory. You need to find it, and add to LD_LIBRARY_PATH:

LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs

License

Dual-licensed to be compatible with the Rust project. Licensed under the Apache License, Version 2.0 or the MIT license, at your option. This file may not be copied, modified, or distributed except according to those terms.

You should check the End User License Agreement, which describes NVIDIA Software License Agreement and CUDA Supplement to Software License Agreement.

cuda-sys's People

Contributors

andrewgaspar avatar bheisler avatar kkebo avatar lutzcle avatar termoshtt 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cuda-sys's Issues

vector_types::bindgen_test_layout_(u)long* fails on windows

failures:
    vector_types::bindgen_test_layout_long1
    vector_types::bindgen_test_layout_long2
    vector_types::bindgen_test_layout_long3
    vector_types::bindgen_test_layout_long4
    vector_types::bindgen_test_layout_ulong1
    vector_types::bindgen_test_layout_ulong2
    vector_types::bindgen_test_layout_ulong3
    vector_types::bindgen_test_layout_ulong4

test result: FAILED. 89 passed; 8 failed; 0 ignored; 0 measured; 0 filtered out
failures:

---- vector_types::bindgen_test_layout_long1 stdout ----
thread 'vector_types::bindgen_test_layout_long1' panicked at 'assertion failed: `(left == right)`
  left: `4`,
 right: `8`: Size of: long1', src\vector_types.rs:778:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- vector_types::bindgen_test_layout_long2 stdout ----
thread 'vector_types::bindgen_test_layout_long2' panicked at 'assertion failed: `(left == right)`
  left: `8`,
 right: `16`: Size of: long2', src\vector_types.rs:825:5

---- vector_types::bindgen_test_layout_long3 stdout ----
thread 'vector_types::bindgen_test_layout_long3' panicked at 'assertion failed: `(left == right)`
  left: `12`,
 right: `24`: Size of: long3', src\vector_types.rs:874:5

---- vector_types::bindgen_test_layout_long4 stdout ----
thread 'vector_types::bindgen_test_layout_long4' panicked at 'assertion failed: `(left == right)`
  left: `16`,
 right: `32`: Size of: long4', src\vector_types.rs:945:5

---- vector_types::bindgen_test_layout_ulong1 stdout ----
thread 'vector_types::bindgen_test_layout_ulong1' panicked at 'assertion failed: `(left == right)`
  left: `4`,
 right: `8`: Size of: ulong1', src\vector_types.rs:801:5

---- vector_types::bindgen_test_layout_ulong2 stdout ----
thread 'vector_types::bindgen_test_layout_ulong2' panicked at 'assertion failed: `(left == right)`
  left: `8`,
 right: `16`: Size of: ulong2', src\vector_types.rs:849:5

---- vector_types::bindgen_test_layout_ulong3 stdout ----
thread 'vector_types::bindgen_test_layout_ulong3' panicked at 'assertion failed: `(left == right)`
  left: `12`,
 right: `24`: Size of: ulong3', src\vector_types.rs:909:5

---- vector_types::bindgen_test_layout_ulong4 stdout ----
thread 'vector_types::bindgen_test_layout_ulong4' panicked at 'assertion failed: `(left == right)`
  left: `16`,
 right: `32`: Size of: ulong4', src\vector_types.rs:981:5

Add a license

The cuda-sys repository seems to be missing a LICENSE file, and there is no mention in the README, either. Am I correct to assume that this project is dual-licensed MIT and Apache 2.0?

attempted to zero-initialize type `CUDA_MEMCPY3D_st`, which is invalid

Calling CUDA_MEMCPY3D_st::default() results in the following error on rustc 1.53.0 for cuda-driver-sys 0.3.0:

thread 'node047' panicked at 'attempted to zero-initialize type `CUDA_MEMCPY3D_st`, which is invalid', /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/mem/mod.rs:625:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:50:5
   3: core::mem::zeroed
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/mem/mod.rs:625:9
   4: <cuda_driver_sys::CUDA_MEMCPY3D_st as core::default::Default>::default
<...>

*-sys crate design

FFI crate separation, e.g. cuda-sys, cudart-sys, and cublas-sys has benefit

  • to separately link to libcuda.so, libcudart.so, libcublas.so
  • to better support cargo feature gates disccused in #5

How to split?

  • cuda-sys
    • FFI for CUDA Driver API (libcuda.so)
  • cudart-sys
    • FFI for CUDA Runtime API (libcudart.so)
  • cublas-sys
    • FFI for cuBLAS

and so on. (edit: Drop cuFFT)

How to manage?

  • each *-sys crates are managed as a subdirectory in this repository
cuda-sys/cuda-sys/Cargo.toml
         cudart-sys/Cargo.toml
         cublas-sys/Cargo.toml

Duplicate struct definitions in both cuda-runtime-sys and cuda-driver-sys

Things like CUstream_st and CUcontext_st are defined in both crates meaning that they need to be cast or transmuted when used across crate boundaries.

Would be nice if shared definitions could be in a shared crate or if cuda-runtime-sys could depend on cuda-driver-sys and reuse the definitions there.

Maintenance this repository

This crates are not maintained now, and I have no time for managing them. If you are interesting to manage and develop this project, please let me know.

Any suggestions are welcome :)

OpenGL interop

I need to access the OpenGL interop functions found in cuda_gl_interop.h. The documentation lists them under the Runtime API so they might fit inside the runtime crate.

It does use a few OpenGL types so a dependency on the gl crate is probably needed as well. I don't know how hard it is to add feature flags for different bindgens so maybe a cuda-gl-interop-sys crate is the better route.

Interop crates/features for D3D could probably be added at the same time in a similar manner.

Dynamic loading

Hello! Do you have plans to add support for dynamic loading cuda library at runtime?
Something like rust-dlopen for example.

With current approach this crate will cause crash if CUDA libraries is not found,
instead of raising error to user (so it will be possible to fallback to cpu/opencl code).

Also, with dynamic loading it will be possible to find CUDA libraries at runtime,
so it won't be necessary to do
export DYLD_LIBRARY_PATH=/usr/local/cuda/lib
in MacOS (and probably LD_LIBRARY_PATH in Linux).

cuSOLVER bindings

I am planning on using cublas and I'd like to leverage the lapack-like utilites in cuSOLVER, such as SVD. Having a -sys crate of bindings would be great!

For reference: cuSOLVER docs

CUDA_LIBRARY_PATH on Ubuntu

Some users of RustaCUDA have found that setting CUDA_LIBRARY_PATH isn't sufficient to allow them to build cuda-sys: bheisler/RustaCUDA#15

I ran into a similar problem while setting up my Travis-CI builds for RustaCUDA on an Ubuntu VM which might be related. If I set CUDA_LIBRARY_PATH to /usr/local/cuda-8.0/targets/x86_64-linux/lib, it could find libcublas.so and libcudart.so but not libcuda.so (which is in /usr/local/cuda-8.0/targets/x86_64-linux/lib/stubs for some reason).

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.