SciNim / nimcuda

Nim bindings for CUDA
Apache License 2.0
42 stars 9 forks source link

Linux: Hardcoded pathes for cuda includes #25

Open dlesnoff opened 3 hours ago

dlesnoff commented 3 hours ago

On Archlinux, I wasn't able to compile the FFT example. I made a specific config.nims file in the example directory from the nimble file and echo'ed all the pathes included.

It turns out that the current nimble file expects cuda to be installed under /usr/local.

Actually, on Archlinux, the CUDA library is installed under /opt/cuda. See GPGPU - ArchWiki My config.nims file looks like the following:

var version=cuda12_6
--hints: off
--linedir: on
--stacktrace: on
--linetrace: on
--debuginfo
switch("cincludes", "/opt/cuda/targets/x86_64-linux/include")
switch("clibdir", "/opt/cuda/targets/x86_64-linux/lib")
switch("path", thisDir() / nimcudaSourceDir(version))
--run

As mentioned in the ArchWiki, one wants to setup environment variables by running a similar script to cuda.sh and using CUDA_PATH in place of the currently hardcoded paths in nimble.

export CUDA_PATH=/opt/cuda
append_path '/opt/cuda/bin'
append_path '/opt/cuda/nsight_compute'
append_path '/opt/cuda/nsight_systems/bin'
export PATH

# Set the default host compiler for nvcc. This will need to be switched back
# and forth between the latest and previous GCC version, whatever nvcc
# currently supports.
export NVCC_CCBIN='/usr/bin/g++-13'
lilkeet commented 2 hours ago

Cuda install autodetection is a much needed feature! :smile: