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

配置VScode开发环境-CUDA编程

如果觉得本篇文章对您的学习起到帮助作用,请 点赞 + 关注 + 评论 ,留下您的足迹💪💪💪

本文主要介绍VScode下的CUDA编程配置,因此记录以备日后查看,同时,如果能够帮助到更多人,也不胜荣幸。

文章目录

  • 一、创建compile_commands.json
    • 1、cmake中使用
    • 2、make中使用
  • 二、安装必要的插件
    • 1.远程连接ssh
    • 2.C/C++
    • 3.C/C++ Extension Pack
    • 4.Nsight Visual Studio Code Edition
    • 5. vscode-cudacpp
  • 三、配置c_cpp_properties.json
  • 四、配置setting.json
  • 五、配置tasks.json
  • 六、配置launch.json

一、创建compile_commands.json

compile_commands.json 文件能够有效提高一些工具(比如vscode)的代码跳转、补全等功能。

1、cmake中使用

cmake工程生成 compile_commands.json 文件比较简单:

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1

2、make中使用

安装bear:

sudo apt-get install bear

执行:

bear -- make -j8

会生成compile_commands.json文件

二、安装必要的插件

1.远程连接ssh

Remote-SSH

2.C/C++

在这里插入图片描述

3.C/C++ Extension Pack

在这里插入图片描述

4.Nsight Visual Studio Code Edition

在这里插入图片描述

5. vscode-cudacpp

在这里插入图片描述

三、配置c_cpp_properties.json

Ctrl+Shift+P搜索C/C++:Edit Configurations(JSON),点击进入:
在这里插入图片描述
随后生成.vscode文件:
在这里插入图片描述
c_cpp_properties.json配置为如下所示:

{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**"],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "c17","cppStandard": "gnu++17","intelliSenseMode": "linux-gcc-x64","configurationProvider": "ms-vscode.makefile-tools","compileCommands": "${workspaceFolder}/compile_commands.json"}],"version": 4
}

“compileCommands”: "${workspaceFolder}/compile_commands.json"为新添加的内容。

配置路径也可以在includePath中进行配置:

{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**","/usr/local/cuda/include/**"],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "c17","cppStandard": "gnu++17","intelliSenseMode": "linux-gcc-x64","configurationProvider": "ms-vscode.makefile-tools"}],"version": 4
}

四、配置setting.json

在.vscode文件夹中创建setting.json文件,添加内容:

{"files.associations": {"*.cu":"cuda-cpp"}
}

参考查询网址vscode language identifier

五、配置tasks.json

1.Ctrl+Shift+P搜索Tasks:Configures Task,点击进入:
在这里插入图片描述
2.选择 使用模板创建tasks.json文件(可能是英文形式)
在这里插入图片描述
3.选择Others
在这里插入图片描述
最终tasks.json文件内容:

{"version": "2.0.0","tasks": [{"label": "make","type": "shell","command": "make -j16"}]
}

六、配置launch.json

1.Ctrl+Shift+P搜索Debug:Add Configuration,点击进入:
在这里插入图片描述2.选择 CUDA C++(CUDA-GDB)
在这里插入图片描述
生成launch.json文件。

增加"program": “${workspaceFolder}/cudaAPP”,cudaAPP是编译出的可执行文件。

{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "CUDA C++: Launch","type": "cuda-gdb","request": "launch","program": "${workspaceFolder}/cudaAPP"},{"name": "CUDA C++: Attach","type": "cuda-gdb","request": "attach"}]
}

如果您觉得这篇文章对你有帮助,记得 点赞 + 关注 + 评论 三连,您只需动一动手指,将会鼓励我创作出更好的文章,快留下你的足迹吧💪💪💪

http://www.lryc.cn/news/195648.html

相关文章:

  • openGauss学习笔记-101 openGauss 数据库管理-管理数据库安全-客户端接入之用SSH隧道进行安全的TCP/IP连接
  • STM32如何使用中断?
  • 用于物体识别和跟踪的下游任务自监督学习-2-(计算机视觉中的距离度量+损失函数)
  • 热成像仪的工作原理及在工业设备状态监测中的应用
  • 什么是库存管理?无需Excel,2023年这几款大热库存管理软件你get了吗?
  • c# xml 参数配置表的使用
  • ubuntu20.04 nerf Instant-ngp
  • 隐写术--python隐写
  • MySQL的InnoDB存储引擎中的自适应哈希索引技术
  • 交互设计主要做什么?新手入门必读
  • 【深度学习实验】循环神经网络(三):门控制——自定义循环神经网络LSTM(长短期记忆网络)模型
  • flutter 消息并发时处理,递归查询
  • 第五十八章 学习常用技能 - 查看查询缓存
  • AI 辅助学 Java | 专栏 1 帮你学 Java
  • 2023_Spark_实验十六:编写LoggerLevel方法及getLocalSparkSession方法
  • 彻底搞懂:防止表单重复提交,前端限制还是后端限制?
  • OCPP1.6协议
  • 【数据存储:小端模式和大端模式】
  • 【git】gitlab安装、备份
  • C51--基本认知
  • centos7 安装 mysql 8.0
  • Vue15 计算属性VS监视属性(侦听属性)
  • 快速全面掌握数据库系统核心知识点
  • 学习笔记 | 音视频 | 推流项目框架及细节
  • 拓扑几何学
  • 1.12.C++项目:仿muduo库实现并发服务器之LoopThreadPool模块的设计
  • SpringBoot介绍
  • 2022最新版-李宏毅机器学习深度学习课程-P17 卷积神经网络CNN
  • 微博清理僵尸粉
  • 创建React Native的第一个hello world工程