标签:ack ref uil aries href app name dep cto
参考:http://galoisplusplus.coding.me/blog/2018/05/22/cudaErrorCudartUnloading/
主要是在linux下,使用cuda安装包里的cuda-memcheck来检查内存,它是类似于valgrind的存在。
首先添加path:
vim ~/.zshrc
export PATH=$PATH:/usr/local/cuda/bin
基于CMake编写C程,cuda相关的内容:
option(use_cuda "Use CUDA?" ON)
if (use_cuda)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CUDA_DIR "/usr/local/cuda")
set(CUDA_INC_DIR "${CUDA_DIR}/include")
set(CUDA_LIB_DIR "${CUDA_DIR}/lib64")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CUDA_DIR "$ENV{CUDA_PATH}")
set(CUDA_INC_DIR "${CUDA_PATH}/include")
set(CUDA_LIB_DIR "${CUDA_DIR/lib/x64}")
endif()
find_package(CUDA REQUIRED)
include_directories(${CUDA_INC_DIR})
link_directories(${CUDA_LIB_DIR})
endif()
if(use_cuda)
list(APPEND TESTBED_DEP_LIBS
cudart
cudart_static
cuda
cublas_device
cudnn
cublas
)
endif()
target_link_libraries(testbed ${TESTBED_DEP_LIBS})
使用:
cd ~/work/mycode
mkdir build
cd build
cmake ..
make
cuda-memcheck ./run
标签:ack ref uil aries href app name dep cto
原文地址:https://www.cnblogs.com/zjutzz/p/10242535.html