I write a sgemm kernel and want to compare it with cublas, when I run the kernel I got the following error
error while loading shared libraries: libcublas.so.12: cannot open shared object file: No such file or directory
nvcc version
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0
I think I should have set all the environment variables correctly, cuda dir is a soft link to cuda-12.0
export CUDA_HOME="${HOME}/.local/cuda"
export LD_LIBRARY_PATH="${CUDA_HOME}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
export PATH="${CUDA_HOME}/bin:$PATH"
Here is my CMakeList.txt
cmake_minimum_required(VERSION 3.18)
set(CUDAToolkit_ROOT ~/.local/cuda)
set(CMAKE_CUDA_ARCHITECTURES "native")
set(CMAKE_CUDA_COMPILER /home/wtx/.local/cuda/bin/nvcc)
project(gemm CUDA CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
add_executable(gemm gemm.cu)
target_link_libraries(gemm -lcublas)
I can compile and run gemm.cu correctly with this command
nvcc gemm.cu -O3 -std=c++17 -L~/.local/cuda/lib64 -lcudart -lcublas -I~/.local/cuda/include
Can someone tell me how I can solve this problem?