当前位置: 首页 > 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/

相关文章:

在 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 Code1.2. C/C1.2.1. Pre-requisites 1.3. Makefile Tools 2. Configuring your project (配置项目)2.1.…...

python中math模块常用函数

文章目录 math模块简介各种三角函数反三角函数取整函数欧几里得距离绝对值最大公约数开根号幂阶乘函数 math模块简介 math模块是python标准库的一部分&#xff0c;提供了对于浮点数相关的数学运算&#xff0c;下面是常用的一些function 各种三角函数反三角函数 math.cos、ma…...

优化 Vue 3 开发体验:配置 Vite 使用 WebStorm 作为 Vue DevTools 的默认编辑器

优化 Vue 3 开发体验&#xff1a;配置 Vite 使用 WebStorm 替代 VS Code 作为 Vue DevTools 的默认编辑器 在 Vue 3 项目开发中&#xff0c;合理配置开发工具可以大大提升我们的工作效率。本文将介绍如何配置 Vite&#xff0c;使其在使用 Vue DevTools 时将默认编辑器从 VS Co…...

【C语言练习(9)—有一个正整数,求是几位数然后逆序打印】

C语言练习&#xff08;9&#xff09; 文章目录 C语言练习&#xff08;9&#xff09;前言题目题目解析结果总结 前言 主要到整数的取余(%)和整数的取商(/)&#xff0c;判断语句if…else if …else的使用 题目 给一个不多于3位的正整数&#xff0c;要求:一、求它是几位数&…...

热敏打印机的控制

首次接触热敏打印机&#xff0c;本来没有特别之处&#xff0c;花了大概十天时间完成一款猫学王热敏打印机&#xff0c;给到客户体验后&#xff0c;客户反馈说打字看起来不明显&#xff0c;打印照片有条纹&#xff0c;所以引起了我对于他的关注&#xff0c;几点不足之处需要优化…...

【closerAI ComfyUI】电商赋能,AI模特套图生产,各种姿势自定义,高度保持人物服饰场景一致性,摆拍街拍专用

closerAIGCcloserAI,一个深入探索前沿人工智能与AIGC领域的资讯平台,我们旨在让AIGC渗入我们的工作与生活中,让我们一起探索AIGC的无限可能性!aigc.douyoubuy.cn 【closerAI ComfyUI】电商赋能,AI模特套图生产,各种姿势自定义,高度保持人物服饰场景一致性,摆拍街拍专用…...

ARM学习(36)静态扫描规则学习以及工具使用

笔者来学习了解一下静态扫描以及其规则,并且亲身是实践一下对arm 架构的代码进行扫描。 1、静态扫描认识 静态扫描:对代码源文件按照一定的规则进行扫描,来发现一些潜在的问题或者风险,因为不涉及代码运行,所以其一般只是发现一些规范或则一些质量问题,当然这些可能存在潜…...

使用 Docker Compose 部署 Redis 主从与 Sentinel 高可用集群

文章目录 使用 Docker Compose 部署 Redis 主从与 Sentinel 高可用集群Redis 主从架构简介Redis Sentinel 简介配置文件1. 主节点配置 (redis-master.conf)2. 从节点配置 (redis-slave1.conf 和 redis-slave2.conf)redis-slave1.confredis-slave2.conf3. Sentinel 配置 (sentin…...

警惕!手动调整服务器时间可能引发的系统灾难

警惕&#xff01;手动调整服务器时间可能引发的系统灾难 1. 鉴权机制1.1 基于时间戳的签名验证1.2 基于会话的认证机制&#xff08;JWT、TOTP&#xff09; 2. 雪花算法生成 ID 的影响2.1 时间戳回拨导致 ID 冲突2.2 ID 顺序被打乱 3. 日志记录与审计3.1 日志顺序错误3.2 审计日…...

MySQL追梦旅途之性能优化

1、索引优化 索引可以显著加速查询操作&#xff0c;但过多或不适当的索引也会带来负面影响&#xff08;如增加写入开销&#xff09;。因此&#xff0c;选择合适的索引至关重要。 创建索引&#xff1a; 为经常用于WHERE子句、JOIN条件和ORDER BY排序的列创建索引。 CREATE I…...

【机器学习】【无监督学习——聚类】从零开始掌握聚类分析:探索数据背后的隐藏模式与应用实例

从零开始掌握聚类分析&#xff1a;探索数据背后的隐藏模式与应用实例 基本概念聚类分类聚类算法的评价指标&#xff08;1&#xff09;内部指标轮廓系数&#xff08;Silhouette Coefficient&#xff09;DB指数&#xff08;Davies-Bouldin Index&#xff09;Dunn指数 &#xff08…...

基于深度Q网络(Deep Q-Network,DQN)的机器人路径规划,可以自定义地图,MATLAB代码

深度Q网络&#xff08;Deep Q-Network&#xff0c;DQN&#xff09;是一种结合了深度学习和Q学习的强化学习算法&#xff0c;由DeepMind在2015年提出。 1. 算法介绍 DQN算法通过使用深度神经网络来近似Q值函数&#xff0c;解决了传统Q-learning在处理具有大量状态和动作的复杂…...

Python-从文件中读取数据-Sat-Sun

10.1 文件读取数据可以整个文件读取&#xff0c;也可以逐行读取。 首先在保存有.py文件的文件夹里创建一个pi_digist.txt文件&#xff0c;文件内容是 3.14 9265 3589执行程序 file_reader.py with open(pi_digist.txt) as file_object: #接受文件名参数&#xff0c;在程序所…...

测试工程师的职业规划

测试人员在管理上的发展 基层测试管理者&#xff1a;测试组长 工作内容&#xff1a;安排小组工作&#xff0c;提升小组成员测试能力&#xff0c;负责重要的测试工作。 负责对象&#xff1a;版本&#xff0c;项目 中层测试管理者&#xff1a;测试经理 负责对象&#xff1…...

使用 Puppeteer 快速上手 Node.js 爬虫

使用 Puppeteer 库通过自动化浏览器来访问百度图片搜索&#xff0c;并在搜索结果中下载图片。代码分为两部分&#xff1a; 自动化浏览器任务&#xff1a;使用 Puppeteer 浏览百度图片搜索并获取图片 URL。图片下载&#xff1a;检查图片 URL 类型&#xff08;base64 或 URL&…...

浏览器的跨域问题与解决方案

浏览器的跨域问题与解决方案 浏览器的跨域问题源于同源策略&#xff08;Same-Origin Policy&#xff09;这一安全机制。同源策略要求两个页面具有相同的协议、域名和端口号&#xff0c;才能相互访问资源和数据。这一机制旨在防止恶意网站执行跨站脚本攻击&#xff0c;从而保护…...

MyBatis一二级缓存的区别?

大家好&#xff0c;我是锋哥。今天分享关于【MyBatis一二级缓存的区别&#xff1f;】面试题。希望对大家有帮助&#xff1b; MyBatis一二级缓存的区别&#xff1f; 1000道 互联网大厂Java工程师 精选面试题-Java资源分享网 MyBatis 的缓存机制分为 一级缓存 和 二级缓存&…...

[2024-12 CISCN 长城杯] Crypto

fffffhash 【也可以看这题&#xff0c;一样的&#xff1a;https://github.com/DownUnderCTF/Challenges_2023_Public/blob/main/crypto/fnv/solve/solution_joseph_LLL.sage】 题目描述&#xff1a; import os from Crypto.Util.number import * def giaogiao(hex_string):b…...

pytorch bilstm crf的教程,注意 这里不支持批处理,要支持批处理 用torchcrf这个。

### Bi-LSTM Conditional Random Field ### pytorch tutorials https://pytorch.org/tutorials/beginner/nlp/advanced_tutorial.html ### 模型主要结构&#xff1a; ![title](sources/bilstm.png) pytorch bilstm crf的教程&#xff0c;注意 这里不支持批处理 Python version…...

Python毕业设计选题:基于django+vue的疫情数据可视化分析系统

开发语言&#xff1a;Python框架&#xff1a;djangoPython版本&#xff1a;python3.7.7数据库&#xff1a;mysql 5.7数据库工具&#xff1a;Navicat11开发软件&#xff1a;PyCharm 系统展示 管理员登录 管理员功能界面 用户管理 员工管理 疫情信息管理 检测预约管理 检测结果…...

conda相比python好处

Conda 作为 Python 的环境和包管理工具&#xff0c;相比原生 Python 生态&#xff08;如 pip 虚拟环境&#xff09;有许多独特优势&#xff0c;尤其在多项目管理、依赖处理和跨平台兼容性等方面表现更优。以下是 Conda 的核心好处&#xff1a; 一、一站式环境管理&#xff1a…...

高危文件识别的常用算法:原理、应用与企业场景

高危文件识别的常用算法&#xff1a;原理、应用与企业场景 高危文件识别旨在检测可能导致安全威胁的文件&#xff0c;如包含恶意代码、敏感数据或欺诈内容的文档&#xff0c;在企业协同办公环境中&#xff08;如Teams、Google Workspace&#xff09;尤为重要。结合大模型技术&…...

新能源汽车智慧充电桩管理方案:新能源充电桩散热问题及消防安全监管方案

随着新能源汽车的快速普及&#xff0c;充电桩作为核心配套设施&#xff0c;其安全性与可靠性备受关注。然而&#xff0c;在高温、高负荷运行环境下&#xff0c;充电桩的散热问题与消防安全隐患日益凸显&#xff0c;成为制约行业发展的关键瓶颈。 如何通过智慧化管理手段优化散…...

3403. 从盒子中找出字典序最大的字符串 I

3403. 从盒子中找出字典序最大的字符串 I 题目链接&#xff1a;3403. 从盒子中找出字典序最大的字符串 I 代码如下&#xff1a; class Solution { public:string answerString(string word, int numFriends) {if (numFriends 1) {return word;}string res;for (int i 0;i &…...

初探Service服务发现机制

1.Service简介 Service是将运行在一组Pod上的应用程序发布为网络服务的抽象方法。 主要功能&#xff1a;服务发现和负载均衡。 Service类型的包括ClusterIP类型、NodePort类型、LoadBalancer类型、ExternalName类型 2.Endpoints简介 Endpoints是一种Kubernetes资源&#xf…...

基于IDIG-GAN的小样本电机轴承故障诊断

目录 🔍 核心问题 一、IDIG-GAN模型原理 1. 整体架构 2. 核心创新点 (1) ​梯度归一化(Gradient Normalization)​​ (2) ​判别器梯度间隙正则化(Discriminator Gradient Gap Regularization)​​ (3) ​自注意力机制(Self-Attention)​​ 3. 完整损失函数 二…...

MinIO Docker 部署:仅开放一个端口

MinIO Docker 部署:仅开放一个端口 在实际的服务器部署中,出于安全和管理的考虑,我们可能只能开放一个端口。MinIO 是一个高性能的对象存储服务,支持 Docker 部署,但默认情况下它需要两个端口:一个是 API 端口(用于存储和访问数据),另一个是控制台端口(用于管理界面…...

深入浅出WebGL:在浏览器中解锁3D世界的魔法钥匙

WebGL&#xff1a;在浏览器中解锁3D世界的魔法钥匙 引言&#xff1a;网页的边界正在消失 在数字化浪潮的推动下&#xff0c;网页早已不再是静态信息的展示窗口。如今&#xff0c;我们可以在浏览器中体验逼真的3D游戏、交互式数据可视化、虚拟实验室&#xff0c;甚至沉浸式的V…...

链式法则中 复合函数的推导路径 多变量“信息传递路径”

非常好&#xff0c;我们将之前关于偏导数链式法则中不能“约掉”偏导符号的问题&#xff0c;统一使用 二重复合函数&#xff1a; z f ( u ( x , y ) , v ( x , y ) ) \boxed{z f(u(x,y),\ v(x,y))} zf(u(x,y), v(x,y))​ 来全面说明。我们会展示其全微分形式&#xff08;偏导…...

UE5 音效系统

一.音效管理 音乐一般都是WAV,创建一个背景音乐类SoudClass,一个音效类SoundClass。所有的音乐都分为这两个类。再创建一个总音乐类&#xff0c;将上述两个作为它的子类。 接着我们创建一个音乐混合类SoundMix&#xff0c;将上述三个类翻入其中&#xff0c;通过它管理每个音乐…...