码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • vscode远程调试Linux CUDA程序


    参考了:CUDA 01 | 第一个程序 - 知乎 (zhihu.com)

    1 本地安装插件:remote-ssh,Microsoft C/C++与NVIDIA Nsight Visual Studio Code Edition。

    2 使用remote-ssh登陆到远程的linux服务器,登陆以后看看安装的插件,需要在远程linux服务器也同时安装插件。确保提到的三个插件在远程端是可以用的。

    3 确保在远程linux服务器已经安装了cuda编译器,没有装的话点下面的链接,输入命令 nvcc -V查看安装情况。

    CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developericon-default.png?t=M85Bhttps://developer.nvidia.com/cuda-downloads

    1. langke@ubuntu:~/my_cuda$ nvcc -V
    2. nvcc: NVIDIA (R) Cuda compiler driver
    3. Copyright (c) 2005-2021 NVIDIA Corporation
    4. Built on Sun_Feb_28_22:34:44_PST_2021
    5. Cuda compilation tools, release 10.2, V10.2.300
    6. Build cuda_10.2_r440.TC440_70.29663091_0

    4 新建一个目录用来测试,例如~/my_cuda,用vscode打开此目录

    5 在.vscode下新建lauch.json,内容如下:

    1. {
    2. // Use IntelliSense to learn about possible attributes.
    3. // Hover to view descriptions of existing attributes.
    4. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    5. "version": "0.2.0",
    6. "configurations": [
    7. {
    8. "name": "CUDA C++: Launch",
    9. "type": "cuda-gdb",
    10. "request": "launch",
    11. "program": "${fileDirname}/${fileBasenameNoExtension}",
    12. "args": [],
    13. "stopAtEntry": false,
    14. //"cwd": "${workspaceFolder}",
    15. "environment": [],
    16. "externalConsole": false,
    17. "MIMode": "gdb",
    18. "setupCommands": [
    19. {
    20. "description": "Enable pretty-printing for gdb",
    21. "text": "-enable-pretty-printing",
    22. "ignoreFailures": true
    23. }
    24. ],
    25. "preLaunchTask": "nvcc build active file",
    26. "postDebugTask": "delete nvcc output file",
    27. }
    28. ]
    29. }

     6 新建tasks.json,内容为:

    1. {
    2. "version": "2.0.0",
    3. "tasks": [
    4. {
    5. "type": "shell",
    6. "label": "nvcc build active file",
    7. "command": "/usr/local/cuda-10.2/bin/nvcc",
    8. "args": [
    9. "${file}",
    10. "-g",
    11. "-o",
    12. "${fileDirname}/${fileBasenameNoExtension}"
    13. ],
    14. "group": {
    15. "kind": "build",
    16. "isDefault": true
    17. }
    18. },
    19. {
    20. "type": "shell",
    21. "label": "delete nvcc output file",
    22. "command": "rm",
    23. "args": [
    24. "${fileDirname}/${fileBasenameNoExtension}"
    25. ],
    26. "presentation": {
    27. "reveal": "silent"
    28. },
    29. "problemMatcher": [],
    30. "group": {
    31. "kind": "build",
    32. "isDefault": true
    33. }
    34. }
    35. ]
    36. }

    7 新建test.cu,输入内容:

    1. #include
    2. int main(int argc, char **argv)
    3. {
    4. printf("cuda test\n");
    5. getchar();
    6. return 0;
    7. }

    8 把窗口切换到test.cu,点击CUDA调试按钮就可以运行了。

     

  • 相关阅读:
    【uniapp】本地资源图片无法通过 WXSS 获取,可以使用网络图片,或者 base64,或者使用image标签
    归并排序精讲
    PaddleMIX学习笔记(1)
    Blazor前后端框架Known-V1.2.9
    【CSS】CSS实现三角形(一)
    学习加密(三)spring boot 使用RSA非对称加密,前后端传递参数加解密
    在数据分析时候的一些小技巧-基于python
    JavaScript基础与变量
    什么是内存碎片?
    IDEA代码重构技巧--拆分类
  • 原文地址:https://blog.csdn.net/oushaojun2/article/details/126836825
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号