bheisler / RustaCUDA

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

Cant find -lcudart #25

Closed dineshadepu closed 5 years ago

dineshadepu commented 5 years ago

Hi all.

I want to contribute to this project. I just got my gpu. I installed nvidia drivers and cuda tool kit.

 --------------------------------------
 dinesh@LAPITOP (master #) /home/dinesh/prog/rust/cuda_rust_check $  
|  Dell Laptop=> nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

I added cuda libraries as given in readme.

# cuda installation
export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}$
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_LIBRARY_PATH="/usr/local/cuda-10.0/lib64"

I want to show that the libraries are available at here

 --------------------------------------
 dinesh@LAPITOP /usr/local/cuda $  
|  Dell Laptop=> ls
bin  extras   lib64      libnvvp  NsightCompute-1.0  nvml  README   share  targets  version.txt
doc  include  libnsight  LICENSE  nsightee_plugins   nvvm  samples  src    tools    

Now when I run the example given in readme I get,

 --------------------------------------
 dinesh@LAPITOP (master #) /home/dinesh/prog/rust/cuda_rust_check $  
|  Dell Laptop=> cargo run
   Compiling cuda_rust_check v0.1.0 (/home/dinesh/prog/rust/cuda_rust_check)                             
warning: unused variable: `context`                                                                      
  --> src/main.rs:26:9                                                                                   
   |                                                                                                     
26 |     let context = Context::create_and_push(                                                         
   |         ^^^^^^^ help: consider using `_context` instead                                             
   |                                                                                                     
   = note: #[warn(unused_variables)] on by default                                                       

error: linking with `cc` failed: exit code: 1                                                            
  |                                                                                                      
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.13petch2da205eam.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.15qy0hkw3l35pdz4.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.1fxjl7nwu306h06k.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.1ptig0mbtxnotkno.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.2dabi26ecn60fl8i.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.2n2enk10fs439jlk.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.34ctdxiv3nfttgb4.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.34f58v21ywaf7ohy.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3780ljs8ayc2aiqg.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3c3ircaumg4xrxhw.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3lcy9r8jbsgr04o0.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3ml5jq9nqmen3vcl.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3q8pb8nreiz32fxh.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3tp77dxjsl4d1bgg.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.3y4wdr0anphrplti.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.44d9st8icqi9qevr.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.44qnnjyev922p73d.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.45zaqay3vbv772ju.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.4gbzt0pjzc91a4t9.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.4hksnxj1hkidpniz.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.4hymhr3qyann8n1d.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.4ku37wlybl4oarhv.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.524inxqvoeq5t16p.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.572wp8cmmtuc6c9x.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.5gt6z5qyk8o63tal.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.hf5soq910o5o67p.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.ipp32by2pbsinsm.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.kn66fwvhog07cs9.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.kpe4hfqqymqoak8.rcgu.o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.wdhfe6pye6ovnz9.rcgu.o" "-o" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/cuda_rust_check-ff11869f86f3bb6d.1tut32buw17s5spe.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/librustacuda-565ea4272efbeddd.rlib" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/librustacuda_core-8314ac49dc75c201.rlib" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/libcuda_sys-a90588f89cd8eefb.rlib" "/home/dinesh/prog/rust/cuda_rust_check/target/debug/deps/libbitflags-de5961d905541c03.rlib" "-Wl,--start-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-52f862a21e09568c.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-b89f1a9b548bfef9.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-a7f738f7aa980965.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-4c9cbe622de116ab.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-48c8a8552cff934e.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-517830e9d56bab97.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-2d44723f32308cf8.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-f2133e8b70369157.rlib" "-Wl,--end-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-71671e8958739d51.rlib" "-Wl,-Bdynamic" "-lcuda" "-lcudart" "-lcublas" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: cannot find -lcudart                                                              
          /usr/bin/ld: cannot find -lcublas                                                              
          collect2: error: ld returned 1 exit status                                                     

error: aborting due to previous error                                                                    

error: Could not compile `cuda_rust_check`.                                                              

To learn more, run the command again with --verbose.

How to fix this?

rusch95 commented 5 years ago

See issue #15

@bheisler Want me to submit a PR updating the instructions for this in the README

dineshadepu commented 5 years ago

This fixed my problem.

bheisler commented 5 years ago

Ideally, cuda-sys should be able to find the libraries on its own - see https://github.com/rust-cuda/cuda-sys/issues/7.