Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to include <stddef.h> + etc. when compiling? #263

Closed
brandonros opened this issue Jun 21, 2024 · 2 comments
Closed

Not able to include <stddef.h> + etc. when compiling? #263

brandonros opened this issue Jun 21, 2024 · 2 comments

Comments

@brandonros
Copy link
Contributor

If I use nvcc, things like

#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <memory.h>

work fine.

If I use

fn device_thread(device_index: usize, lowest_target_seen: Arc<RwLock<Vec<u8>>>) -> Result<(), Box<dyn Error>> {
    // get device
    let device = cudarc::driver::CudaDevice::new(device_index)?;

    // bind to thread
    device.bind_to_thread()?;

    // compile program
    log::info!("device_index = {device_index} compiling...");
    let ptx = cudarc::nvrtc::compile_ptx_with_opts(include_str!("./kernel.cu"), cudarc::nvrtc::CompileOptions {
        include_paths: vec![
            "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\include\\".into(),
            "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.5\\include\\cuda\\std\\detail\\libcxx\\include\\".into(),
        ],
        ..Default::default()
    })?;
    device.load_ptx(ptx, "my_module", &["try_hashes_kernel"])?;
    log::info!("device_index = {device_index} compiled");

(I've tried all variations of with + without include paths), I get no luck... Is this something that could be clarified better with an example/documentation? Am I doing something wrong or is this expected?

@brandonros
Copy link
Contributor Author

As a workaround for anybody who lands on this,

make sure the exported symbol (your kernel) you want is marked extern "C" __global__

then

nvcc -keep kernel.cu

then

device.load_ptx(cudarc::nvrtc::Ptx::from_file("./kernel/kernel.ptx"), "my_module", &["try_hashes_kernel"])?;

@coreylowman
Copy link
Owner

Where are those files that you tried to include located on your system? It likely is some difference in default include paths for nvrtc and nvcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants