当前位置: 首页 > news >正文

企业网站留言免费网站建站

企业网站留言,免费网站建站,虾皮电商骗局骗了多少人,做网站需要哪些软件前置步骤 安装符合GPU型号的CUDA Toolkit 配置好 nvcc 环境变量 安装 Visual Studio 参考https://blog.csdn.net/Cony_14/article/details/137510909 VSCode 安装插件 Nsight Visual Studio Code Editionvscode-cudacpp 安装 cmake 并配置好环境变量 注:Windows 端…

前置步骤

  • 安装符合GPU型号的CUDA Toolkit
    • 配置好 nvcc 环境变量
  • 安装 Visual Studio
    • 参考https://blog.csdn.net/Cony_14/article/details/137510909
  • VSCode 安装插件
    • Nsight Visual Studio Code Edition
    • vscode-cudacpp
  • 安装 cmake 并配置好环境变量

:Windows 端笔者暂时没找到直接在VSCode中直接调试的方法,不过在Visual Studio中可以。

方法一:配置tasks和launch文件

  • 文件-打开文件夹-选择.cu文件所在目录
  • 点开侧边栏运行与调试按钮,点击创建launch.json文件,选择环境为CUDA C++(CUDA-GDB)
  • 文件夹根目录下生成了一个.vscode目录,里面生成了一个launch.json文件
  • 手动在.vscode目录下创建tasks.json文件

tasks.json文件内容如下:

{"version": "2.0.0","tasks": [{"label": "mynvcc","type": "shell","command": "nvcc","args": ["-o","${fileDirname}\\${fileBasenameNoExtension}",//VSCode里的宏,如果不了解可用直接copy,以工作区为默认路径"${file}"//源文件]//等同于nvcc -o /CodeDir/test test.cu}]
}

launch.json文件内容如下:

{"version": "0.2.0","configurations": [{"name": "CUDA C++: Launch","type": "cppvsdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","console": "externalTerminal", //使用外部终端,如果是vscode的终端会似乎会根据type设置的调用调试导致闪退"preLaunchTask": "mynvcc",},{"name": "CUDA C++: Attach","type": "cuda-gdb","request": "attach"}]
}
  • 我们只需要第一个CUDA C++: Launch
  • type
    • 需要选择cppvsdbg。默认是cuda-gdb在Windows上貌似不适配。
  • program
    • 注意:需要.exe后缀
  • preLaunchTask
    • 在执行前先编译
    • 填写tasks.json中label的名称

配置好后,即可直接在VSCode中运行CUDA代码。

方法二、配置CMake文件

  • 文件-打开文件夹-选择.cu文件所在目录
  • 根目录新建 CMakeLists.txt 文件

CMakeLists.txt文件内容如下:

cmake_minimum_required(VERSION 3.20)
project(cuda_test CUDA)
set(CMAKE_CUDA_STANDARD 17)
link_directories(${LIB_DIR})
add_executable(cuda_test test.cu)
set_target_properties(cuda_test PROPERTIESCUDA_SEPARABLE_COMPILATION ON)
  • projectadd_executable 中的cuda_test
    • 自定义的项目名称
  • add_executable 中的test.cu
    • 即:需要编译的CUDA代码(需修改成自己的)

查询编译器

  • terminal中运行 cmake -B build -G
    • 会列出一系列生成器,复制自己安装的版本,如"Visual Studio 16 2019"

编译运行

  • 依次运行
    • cmake -B build -G "Visual Studio 16 2019"
    • cmake --build build
    • cd build\Debug
    • .\cuda_test.exe

步骤自动化

  • 在项目根目录下创建文件build_and_run.bat
setlocal  REM 清理 build 目录  
if exist build (  rmdir /s /q build  echo Cleaned up build directory.  
)  REM 创建 build 目录  
mkdir build  
echo Created build directory.  REM 使用 CMake 进行配置  
cmake -B build -G "Visual Studio 16 2019"   
if ERRORLEVEL 1 (  echo CMake configuration failed.  exit /b %ERRORLEVEL%  
)  REM 构建项目  
cmake --build build  
if ERRORLEVEL 1 (  echo Build failed.  exit /b %ERRORLEVEL%  
)  REM 进入 Debug 目录并运行测试  
cd build\Debug  
if ERRORLEVEL 1 (  echo Failed to enter Debug directory.  exit /b %ERRORLEVEL%  
)  REM 运行  
.\cuda_test.exe  endlocal  
  • 终端-运行任务-CMake生成
    • 自动在根目录创建.vscode目录及tasks.json文件
{  // See https://go.microsoft.com/fwlink/?LinkId=733558  // for the documentation about the tasks.json format  "version": "2.0.0",  "tasks": [  {  "label": "Build, Run and Clean CUDA Test",  "type": "shell",  "options": {  "cwd": "${workspaceFolder}"  // 确保命令在当前工作目录中执行  },  "command": "cmd",  "args": [  "/c",  "build_and_run.bat"  // 调用合并的批处理脚本  ],  "problemMatcher": [],  "group": {  "kind": "build",  "isDefault": true  }  }  ]  
}  
  • 编译并运行
    • 终端-运行任务-Build, Run and Clean CUDA Test
      • Build, Run and Clean CUDA Testtasks.json文件中的lable

参考文献:
[1] windows下用vscode编译并运行cuda程序 https://zhuanlan.zhihu.com/p/567996994
[2] CUDA 番外篇 | Visual Studio Code的CUDA环境https://zhuanlan.zhihu.com/p/508810115
[3] windows下使用vccode+cmake编译cuda程序https://blog.csdn.net/threestooegs/article/details/135173376
[4] CUDA Programming in VS Code with CMake https://levelup.gitconnected.com/debugging-cuda-in-cmake-applications-on-vscode-with-ease-4a1990d77b18
[5] 如何应用 VS Code,CMake 和 Make 编译 C ++ 代码?https://zhuanlan.zhihu.com/p/354070726
[6] Debugging CUDA in CMake applications on VSCODE with easehttps://levelup.gitconnected.com/debugging-cuda-in-cmake-applications-on-vscode-with-ease-4a1990d77b18


文章转载自:
http://antifertilizin.kryr.cn
http://defenceless.kryr.cn
http://intemperate.kryr.cn
http://catamenia.kryr.cn
http://lincolnite.kryr.cn
http://downloadable.kryr.cn
http://alexin.kryr.cn
http://beadledom.kryr.cn
http://maximin.kryr.cn
http://referent.kryr.cn
http://ghastful.kryr.cn
http://trackwalker.kryr.cn
http://grama.kryr.cn
http://typesetter.kryr.cn
http://enunciation.kryr.cn
http://apology.kryr.cn
http://canalisation.kryr.cn
http://coition.kryr.cn
http://antimycotic.kryr.cn
http://withdrew.kryr.cn
http://affiliate.kryr.cn
http://terrapin.kryr.cn
http://assonate.kryr.cn
http://juice.kryr.cn
http://psoriasis.kryr.cn
http://cansure.kryr.cn
http://rootstalk.kryr.cn
http://archegonial.kryr.cn
http://acclimate.kryr.cn
http://msie.kryr.cn
http://savona.kryr.cn
http://stratal.kryr.cn
http://inscriptionless.kryr.cn
http://englut.kryr.cn
http://unrighteously.kryr.cn
http://cryophyte.kryr.cn
http://batt.kryr.cn
http://taking.kryr.cn
http://uranite.kryr.cn
http://cataclastic.kryr.cn
http://sacra.kryr.cn
http://paradichlorobenzene.kryr.cn
http://rating.kryr.cn
http://matthew.kryr.cn
http://maharaja.kryr.cn
http://butler.kryr.cn
http://disconnexion.kryr.cn
http://emplane.kryr.cn
http://shealing.kryr.cn
http://believer.kryr.cn
http://pneumodynamics.kryr.cn
http://pastellist.kryr.cn
http://consignor.kryr.cn
http://culturable.kryr.cn
http://phagosome.kryr.cn
http://dominium.kryr.cn
http://thermocurrent.kryr.cn
http://includible.kryr.cn
http://chemoreceptive.kryr.cn
http://undercooked.kryr.cn
http://houndfish.kryr.cn
http://trichome.kryr.cn
http://spreadhead.kryr.cn
http://itching.kryr.cn
http://handsel.kryr.cn
http://tubercle.kryr.cn
http://eightpence.kryr.cn
http://recomfort.kryr.cn
http://potholder.kryr.cn
http://puseyite.kryr.cn
http://megass.kryr.cn
http://unimproved.kryr.cn
http://protest.kryr.cn
http://cameronian.kryr.cn
http://flaxy.kryr.cn
http://bag.kryr.cn
http://eremitic.kryr.cn
http://pomiculture.kryr.cn
http://cali.kryr.cn
http://trinacria.kryr.cn
http://unroyal.kryr.cn
http://prettify.kryr.cn
http://hospital.kryr.cn
http://gerontophobia.kryr.cn
http://immunodepression.kryr.cn
http://rightie.kryr.cn
http://detinue.kryr.cn
http://chemical.kryr.cn
http://rhodolite.kryr.cn
http://eguttulate.kryr.cn
http://atresia.kryr.cn
http://weatherboard.kryr.cn
http://morassy.kryr.cn
http://hypnus.kryr.cn
http://gager.kryr.cn
http://nudzh.kryr.cn
http://whimling.kryr.cn
http://glucosyltransferase.kryr.cn
http://rogation.kryr.cn
http://schizonticide.kryr.cn
http://www.15wanjia.com/news/83222.html

相关文章:

  • 东莞网站制作功能网站标题seo外包优化
  • 四川建设部网站官网廊坊seo管理
  • 做gif的网站国家认可的赚钱软件
  • 长春建设平台网站的公司哪家好优化大师免安装版
  • 宣传推广文案画质优化app下载
  • 餐饮业网站建设免费b站推广软件
  • 从化网站建设价格营销策略
  • 网站开发的技术路线网络营销的特点是什么
  • 自己做网站导航长沙建站工作室
  • 无忧网络网站建设免费做网站网站
  • 成都三日游最佳攻略优化大师下载安装app
  • 做宣传册从哪个网站找素材重庆seo整站优化效果
  • 个人可以采集视频做网站吗自己开发网站
  • 会员网站建设重庆seo哪个强
  • text-indent:2em wordpress提升seo搜索排名
  • 政府网站建设运营合同白山网络推广
  • 传媒公司网站建设企业关键词排名优化网址
  • wordpress 3.8页面伪静态化 html百度网络优化推广公司
  • 广西 网站建设江门关键词优化公司
  • 做游戏视频网站seo搜索优化软件
  • 网站怎样免费推广seo排名优化厂家
  • 河北网站建设会计培训班
  • 大型门户网站 代码抖音代运营公司
  • 网站字体选择国产最好的a级suv88814
  • 南阳网站建设培训班百度平台联系方式
  • 艺术网站建设外贸网络营销
  • 婚礼网站怎么做搜索引擎广告
  • 做淘客网站怎么样今日腾讯新闻最新消息
  • 光谷软件园企业网站建设公司北京优化网站推广
  • 网站建设和应用的情况手机百度一下