What's the best way? Here are my solutions:
echo $PATH | sed "s/:/\n/g" | grep "cuda/bin" | sed "s/\/bin//g" | head -n 1
which nvcc | sed "s/\/bin\/nvcc//"
which nvcc | head -c -10
They are all PATH-based. One could locate libraries instead. It would be more robust if there are no CUDA paths in PATH.
I'm using this in a Makefile.
How does something based onldconfig -p | grep libcuda
sound ? Considering an appropriate ldconfig setup is explicitly advised at the end of the installation of the CUDA toolkit, it should do the trick without path nicely, I think.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With