wsl-ubuntu配置cuda

下载cuda

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=WSL-Ubuntu&target_version=2.0&target_type=deb_network

下载cudnn

https://developer.nvidia.com/cudnn

 sudo cp -r /mnt/e/Edgedownload/cudnn-linux-x86_64-8.6.0.163_cuda11-archive/cudnn-linux-x86_64-8.6.0.163_cuda11-archive/include/* /usr/local/cuda-11.8/targets/x86_64-linux/include/
 
 sudo cp -r /mnt/e/Edgedownload/cudnn-linux-x86_64-8.6.0.163_cuda11-archive/cudnn-linux-x86_64-8.6.0.163_cuda11-archive/lib/* /usr/local/cuda-11.8/targets/x86_64-linux/lib/

cmakelists

cmake_minimum_required(VERSION 3.10)

project(test_torch)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
find_package(PythonInterp REQUIRED)
set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-11.8)
set(  CUDA_CUDART_LIBRARY /usr/local/cuda-11.8/targets/x86_64-linux/lib/libcudart.so)
set(CMAKE_CUDA_COMPILER /usr/local/cuda-11.8/bin/nvcc)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
# 61根据自己的显卡更改 https://developer.nvidia.com/cuda-gpus
   set(CMAKE_CUDA_ARCHITECTURES 61)
endif()

set(Torch_DIR /mnt/h/libtorch-cxx11-abi-shared-with-deps-1.13.0+cu117/libtorch/share/cmake/Torch )

find_package(Torch REQUIRED)

add_executable(test_torch
       mian.cpp)
target_compile_features(test_torch PUBLIC cxx_range_for)
target_link_libraries(test_torch "${TORCH_LIBRARIES}")
target_include_directories(test_torch PRIVATE CUDA_INCLUDE_DIRS)
set_property(TARGET test_torch PROPERTY CXX_STANDARD 14) 

问题:用不了cuda??

posted @ 2022-11-16 10:26  榴红八色鸫  阅读(172)  评论(0)    收藏  举报