negativo17 / cuda

NVIDIA Compute Unified Device Architecture Toolkit
14 stars 1 forks source link

Building a CUDA program that assumes monolithic CUDA_HOME installation (/usr/local/cuda) #7

Closed mjmg closed 6 years ago

mjmg commented 6 years ago

I'm having problems compiling a program in Fedora 2X with the following issue remaining open: https://github.com/njm18/gmatrix/issues/10

Since the developer has not yet replied, what would be your suggested workaround for building a program that is not aware that cuda development files are in "standard Fedora locations" and assumes a single monolithic CUDA_HOME environment set up (usually in /usr/local/cuda)?

isloven commented 6 years ago

Simone provides pkg-config files w/ cuda:

$ pkg-config --cflags cuda -I/usr/include/cuda

$ pkg-config --libs cuda -lcuda

Seeing how pkg-config is the standard way of handling this stuff on Linux, I would recommend going that route. You might be able to send a patch to the project maintainer to add this to the project. The pkg-config command has "--silience-errors" option which could be used without affecting other setups. Good luck.

scaronni commented 6 years ago

Sorry for the late reply. There are multiple ways to specify the various locations:

$ cat /etc/profile.d/cuda.sh 
if [ -x /usr/bin/cuda-g++ ]; then
  export HOST_COMPILER=/usr/bin/cuda-g++
fi

if [ -x /usr/libexec/cuda/open64/bin/nvopencc ]; then
  export PATH=$PATH:/usr/libexec/cuda/open64/bin
fi

if [ -d /usr/include/cuda ]; then
  export CUDA_INCLUDE_DIRS=/usr/include/cuda
fi

These are printed out when you execute nvcc in verbose mode:

$ cat /usr/bin/nvcc.profile 
NVVMIR_LIBRARY_DIR = /usr/share/cuda
PATH += /usr/libexec/cuda/open64/bin:
INCLUDES += "-I/usr/include/cuda"
LIBRARIES =+ "-L/usr/lib64"
CUDAFE_FLAGS +=
PTXAS_FLAGS +=

So you probably just need to specify the variable you require just before the command.

And also, you could declare CUDA_HOME to be /usr. If that works, I might add it to the default environment variable.