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

在 Visual Studio Code 中编译、调试和执行 Makefile 工程 llama2.c

在 Visual Studio Code 中编译、调试和执行 Makefile 工程 llama2.c

  • 1. Installing the extension (在 Visual Studio Code 中安装插件)
    • 1.1. Extensions for Visual Studio Code
    • 1.2. C/C++
      • 1.2.1. Pre-requisites
    • 1.3. Makefile Tools
  • 2. Configuring your project (配置项目)
    • 2.1. `/home/yongqiang/llm_work/llama2.c/`
    • 2.2. 创建工作区设置文件 `.vscode/settings.json`
    • 2.3. Makefile: Project Outline
  • 3. Debugging and running targets (调试并运行目标)
    • 3.1. 配置 `.vscode/settings.json` 文件中 `binaryArgs` 的运行参数
  • References

1. Installing the extension (在 Visual Studio Code 中安装插件)

1.1. Extensions for Visual Studio Code

https://marketplace.visualstudio.com/vscode

在这里插入图片描述

1.2. C/C++

C/C++ for Visual Studio Code

The C/C++ extension adds language support for C/C++ to Visual Studio Code, including editing (IntelliSense) and debugging features.

在这里插入图片描述

1.2.1. Pre-requisites

C++ is a compiled language meaning your program’s source code must be translated (compiled) before it can be run on your computer. VS Code is first and foremost an editor, and relies on command-line tools to do much of the development workflow. The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer.

  • C++ compiler pre-installed
  • C++ debugger pre-installed

Here is a list of compilers and architectures per platform officially supported by the extension.

PlatformCompilersArchitectures
WindowsMSVC, Clang, GCCx64, x86, arm64, arm
LinuxClang, GCCx64, x86, arm64, arm
macOSClang, GCCx64, x86, arm64

1.3. Makefile Tools

VS Code Makefile Tools

This extension provides IntelliSense configurations to the VS Code C/C++ Extension for Makefile projects. It also provides convenient commands to build, debug, and run your targets.

在这里插入图片描述

2. Configuring your project (配置项目)

2.1. /home/yongqiang/llm_work/llama2.c/

Help -> Welcome -> Open Folder

在这里插入图片描述

2.2. 创建工作区设置文件 .vscode/settings.json

Command Palette (Ctrl + Shift + P)

在这里插入图片描述

Preferences: Open Workspace Settings (JSON)

在这里插入图片描述

/home/yongqiang/llm_work/llama2.c/.vscode/settings.json

2.3. Makefile: Project Outline

  • Configuration: [Default]

Hover over Configuration and select the pencil icon to choose a configuration for your project.
将鼠标悬停在 Configuration 上并选择铅笔图标来为你的项目选择配置。

在这里插入图片描述

在这里插入图片描述

  • Build target: [rundebug]

Choose a Build target by selecting the pencil icon that appears on hover.
通过选择悬停时出现的铅笔图标来选择构建目标。

在这里插入图片描述

  • Launch target: [run]

在这里插入图片描述

  • Launch target: [runq]

在这里插入图片描述

  • Makefile: [/home/yongqiang/llm_work/llama2.c/Makefile]

在 VS Code 中使用快捷键 Ctrl + Shift + P,输入并选择 Makefile: Configure

在这里插入图片描述

The extension will activate when it finds a Makefile in your ${workspaceFolder}.

在这里插入图片描述

在这里插入图片描述

  • .vscode/settings.json
{"makefile.launchConfigurations": [{"cwd": "/home/yongqiang/llm_work/llama2.c","binaryPath": "/home/yongqiang/llm_work/llama2.c/run","binaryArgs": []},{"cwd": "/home/yongqiang/llm_work/llama2.c","binaryPath": "/home/yongqiang/llm_work/llama2.c/runq","binaryArgs": []}]
}

在这里插入图片描述

3. Debugging and running targets (调试并运行目标)

在这里插入图片描述

After setting the Build target, click the Build icon.

Makefile: Build the current target
在这里插入图片描述

Once the Launch target is set, select the Debug icon to start a debugging session.

Makefile: Debug the selected binary target
在这里插入图片描述

To run the program without debugging, select the Run in Terminal button.

Makefile: Run the selected binary target in the terminal
在这里插入图片描述

If you need to pass additional arguments to your targets, update the makefile.launchConfigurations by adding the binaryArgs property to the configuration.

(base) yongqiang@yongqiang:~/llm_work/llama2.c$ "/home/yongqiang/llm_work/llama2.c/run" 
Usage:   run <checkpoint> [options]
Example: run model.bin -n 256 -i "Once upon a time"
Options:-t <float>  temperature in [0,inf], default 1.0-p <float>  p value in top-p (nucleus) sampling in [0,1] default 0.9-s <int>    random seed, default time(NULL)-n <int>    number of steps to run for, default 256. 0 = max_seq_len-i <string> input prompt-z <string> optional path to custom tokenizer-m <string> mode: generate|chat, default: generate-y <string> (optional) system prompt in chat mode
(base) yongqiang@yongqiang:~/llm_work/llama2.c$ 

3.1. 配置 .vscode/settings.json 文件中 binaryArgs 的运行参数

If you need to pass additional arguments to your targets, update the makefile.launchConfigurations by adding the binaryArgs property to the configuration.

./run stories15M.bin -n 256 -i "Once upon a time"

/home/yongqiang/llm_work/llama2.c/.vscode/settings.json

{"makefile.launchConfigurations": [{"cwd": "/home/yongqiang/llm_work/llama2.c","binaryPath": "/home/yongqiang/llm_work/llama2.c/run","binaryArgs": ["stories15M.bin", "-n", "256", "-i", "\"Once upon a time\""]},{"cwd": "/home/yongqiang/llm_work/llama2.c","binaryPath": "/home/yongqiang/llm_work/llama2.c/runq","binaryArgs": []}]
}

在这里插入图片描述

(base) yongqiang@yongqiang:~/llm_work/llama2.c$ "/home/yongqiang/llm_work/llama2.c/run" stories15M.bin -n 256 -i "Once upon a time"
Once upon a time, there was a cute little cat named Fluffy. Fluffy loved to climb trees. One sunny day, Fluffy saw a big tree and wanted to climb it.
Fluffy started to climb the tree. It was not easy, but Fluffy did not give up. Fluffy used its muscles to help get to the top. When Fluffy got to the top, it was so much fun!
Fluffy was very happy. Fluffy learned that when you try and do big things, you can do anything. And that is how Fluffy's love for climbing trees made her very happy.
achieved tok/s: 25.695931
(base) yongqiang@yongqiang:~/llm_work/llama2.c$ 

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] Makefile support in Visual Studio Code!, https://devblogs.microsoft.com/cppblog/now-announcing-makefile-support-in-visual-studio-code/

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

相关文章:

  • python中math模块常用函数
  • 优化 Vue 3 开发体验:配置 Vite 使用 WebStorm 作为 Vue DevTools 的默认编辑器
  • 【C语言练习(9)—有一个正整数,求是几位数然后逆序打印】
  • 热敏打印机的控制
  • 【closerAI ComfyUI】电商赋能,AI模特套图生产,各种姿势自定义,高度保持人物服饰场景一致性,摆拍街拍专用
  • ARM学习(36)静态扫描规则学习以及工具使用
  • 使用 Docker Compose 部署 Redis 主从与 Sentinel 高可用集群
  • 警惕!手动调整服务器时间可能引发的系统灾难
  • MySQL追梦旅途之性能优化
  • 【机器学习】【无监督学习——聚类】从零开始掌握聚类分析:探索数据背后的隐藏模式与应用实例
  • 基于深度Q网络(Deep Q-Network,DQN)的机器人路径规划,可以自定义地图,MATLAB代码
  • Python-从文件中读取数据-Sat-Sun
  • 测试工程师的职业规划
  • 使用 Puppeteer 快速上手 Node.js 爬虫
  • 浏览器的跨域问题与解决方案
  • MyBatis一二级缓存的区别?
  • [2024-12 CISCN 长城杯] Crypto
  • pytorch bilstm crf的教程,注意 这里不支持批处理,要支持批处理 用torchcrf这个。
  • Python毕业设计选题:基于django+vue的疫情数据可视化分析系统
  • tomcat被检测到目标URL存在htp host头攻击漏洞
  • 1.初识python
  • 【密码学】ZUC祖冲之算法
  • Python面试常见问题及答案8
  • ASP.net Core EntityFramework Code EF code 汇总
  • u3d动画系统五【StateMachineBehaviour类】
  • IS-IS协议
  • 使用C++实现RSA加密解密
  • C++归并与快速
  • 金蝶云苍穹踩过的坑(慢慢更新)
  • AndroidStudio——安卓项目结构与文件介绍