bheisler / RustaCUDA

Rusty wrapper for the CUDA Driver API
Apache License 2.0
758 stars 60 forks source link

How to run the example with add.cubin file? #47

Open VariniChiara opened 4 years ago

VariniChiara commented 4 years ago

I'm trying to run the example with the add.cubin kernel but it seems not to work.

I've tried "... let module_data = CString::new(include_str!("../add.cubin"))?; let module = Module::load_from_string(&module_data)?; ..."

but I got error: src/../add.cubin wasn't a utf-8 file

the I've tried "... let filename = CString::new("./sub.cubin")?; let module = Module::load_from_file(&filename)?; ..." but I got Error: InvalidSouce

bheisler commented 4 years ago

That's a fair point! I don't know, I've only ever used PTX files.

include_str! won't work with binary files. I always meant to create an include_cstr! macro if I could figure out how to implement it, but never got around to it.

Using load_from_file is probably the right way to go, but you'll need to make sure your path is correct. If you're using relative paths, then I think they'll be relative to the current working directory when you run the program.

VariniChiara commented 4 years ago

Unfortunately even the load_from_file() doesn't work even if I set the correct path, Is there a workaround?

LutzCle commented 4 years ago

I'm successfully using load_from_file to load a fatbin. You can generate a fatbin by passing '-fatbin' to nvcc.

How are you compiling the binary?

taotaolin commented 3 years ago

I'm successfully using load_from_file to load a fatbin. You can generate a fatbin by passing '-fatbin' to nvcc.

How are you compiling the binary?

I tried to use nvcc-fatbin add.cu to compile the file using load_from_fiile to load. Error NoBinaryForGpu
Can you directly load the CU file to call