ubantu20.04安装gem5

前言

在安装gem5时,花了很长时间,主要是遇到一些奇奇怪怪的错误。在此记录一下。

参考资料

1\] https://www.gem5.org/documentation/learning_gem5/part1/building/ \[2\] https://blog.csdn.net/weixin_46841376/article/details/137884041 ### 过程 1. 安装必要的包 ```c sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python-dev python ``` 这里要注意下面几个包的版本: (1)安装gcc ```c sudo apt install build-essential ``` 这里gcc的版本最好是10+。可以用gcc --version查看其版本,不符合的调整一下。 (2)安装SCons ```c sudo apt install scons ``` 这里的SCons的版本最好是3.0+ (3)安装python ```c sudo apt install python3-dev ``` python的版本最好是3.6+,可以使用python3 --version查看版本。 (4)安装protobuf protobuf最好是protobuf 2.1+的版本,可以使用protoc --version查看版本号。 ```c sudo apt install libprotobuf-dev protobuf-compiler libgoogle-perftools-dev ``` (5)安装Boost ```c sudo apt install libboost-all-dev ``` 2. 克隆gem5包 可以用gitee的包,下载速度快一些 ```c git clone https://gitee.com/koverlu/gem5.git ``` 3. 编译安装gem5 接下来就可以编译了。首先进入gem5目录 ```c cd gem5 ``` 然后开始编译 ```c python3 `which scons` build/X86/gem5.opt -j32 ``` 上面这句代码的-j32是指定编译时使用的并行度,即同时进行的编译任务数。这里的 32 表示将使用32个并行任务来编译 gem5。 有些文章说,32这个数字由电脑CPU的数量决定的。我电脑是64个核,使用-j64后报错了。报错信息如下: ```c scons: *** [build/X86/python/_m5/param_MultiperspectivePerceptron.cc] Error 134 scons: building terminated because of errors. ``` 这只是报错的小部分,有很多报错信息都显示Error 134。在stackoverflow上看到一条帖子,说是因为out of memory的缘故。 out of memory的解决办法目前有两种,一是增加交换区的大小【我觉得麻烦没试哈哈哈哈】二是减小编译的并行度,我把-j64改成-j32,就可以了 编译成功应该是这个样子: ```c [ CXX] src/mem/ruby/system/HTMSequencer.cc -> X86/mem/ruby/system/HTMSequencer.o [ CXX] X86/python/_m5/param_RubyHTMSequencer.cc -> .o [ CXX] X86/python/_m5/param_DMASequencer.cc -> .o [ CXX] src/mem/ruby/system/RubyPort.cc -> X86/mem/ruby/system/RubyPort.o [ CXX] src/mem/ruby/system/RubyPortProxy.cc -> X86/mem/ruby/system/RubyPortProxy.o [ CXX] src/mem/ruby/system/RubySystem.cc -> X86/mem/ruby/system/RubySystem.o [ CXX] src/mem/ruby/system/Sequencer.cc -> X86/mem/ruby/system/Sequencer.o [ CXX] X86/python/m5/defines.py.cc -> .o [ CXX] X86/python/m5/info.py.cc -> .o [ CXX] src/base/date.cc -> X86/base/date.o [ LINK] -> X86/gem5.opt scons: done building targets. *** Summary of Warnings *** Warning: Couldn't find HDF5 C++ libraries. Disabling HDF5 support. Warning: Header file not found. This host has no capstone library installed. Warning: Can not enable KVM, host seems to lack KVM support ``` 出现scons: done building targets.这句话就没问题啦\~\~ 4. 测试是否安装成功gem5 在gem5的目录下新建一个hello-world.py文件,文件内容如下: ```c from gem5.isas import ISA from gem5.components.boards.simple_board import SimpleBoard from gem5.components.cachehierarchies.classic.no_cache import NoCache from gem5.components.memory.single_channel import SingleChannelDDR3_1600 from gem5.components.processors.simple_processor import SimpleProcessor from gem5.components.processors.cpu_types import CPUTypes from gem5.resources.resource import Resource from gem5.simulate.simulator import Simulator # Obtain the components. cache_hierarchy = NoCache() memory = SingleChannelDDR3_1600("1GiB") processor = SimpleProcessor(cpu_type=CPUTypes.ATOMIC, isa=ISA.X86, num_cores=1) #Add them to the board. board = SimpleBoard( clk_freq="3GHz", processor=processor, memory=memory, cache_hierarchy=cache_hierarchy, ) # Set the workload. binary = Resource("x86-hello64-static") board.set_se_binary_workload(binary) # Setup the Simulator and run the simulation. simulator = Simulator(board=board) simulator.run() ``` 保存退出文件后运行下面命令: ```c build/X86/gem5.opt hello-world.py ``` 如果出现Hello World!字样则表明成功安装!

相关推荐
武子康3 小时前
大数据-237 离线数仓 - Hive 广告业务实战:ODS→DWD 事件解析、广告明细与转化分析落地
大数据·后端·apache hive
大大大大晴天5 小时前
Flink生产问题排障-Kryo serializer scala extensions are not available
大数据·flink
Elasticsearch1 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
Elasticsearch2 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
武子康2 天前
大数据-236 离线数仓 - 会员指标验证、DataX 导出与广告业务 ODS/DWD/ADS 全流程
大数据·后端·apache hive
武子康3 天前
大数据-235 离线数仓 - 实战:Flume+HDFS+Hive 搭建 ODS/DWD/DWS/ADS 会员分析链路
大数据·后端·apache hive
郑州光合科技余经理4 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php
DianSan_ERP4 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
够快云库4 天前
能源行业非结构化数据治理实战:从数据沼泽到智能资产
大数据·人工智能·机器学习·企业文件安全
AI周红伟4 天前
周红伟:智能体全栈构建实操:OpenClaw部署+Agent Skills+Seedance+RAG从入门到实战
大数据·人工智能·大模型·智能体