苹果芯片(M1/Apple Chip)通过UTM安装x86架构虚拟机指南/性能测试(以ubuntu18.04为例)
Posted Overflow_me
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了苹果芯片(M1/Apple Chip)通过UTM安装x86架构虚拟机指南/性能测试(以ubuntu18.04为例)相关的知识,希望对你有一定的参考价值。
苹果芯片性能强功耗低,但是虚拟机作为计算机常用软件,大多数虚拟软件在苹果芯片上仅支持原生架构(ARM)的虚拟机。然而,常用的开发环境是属于x86架构的。那么,如何在苹果芯片上运行不同架构的虚拟机呢?
UTM底层基于QEMU实现,可以通过指令转译运行不同架构的系统,这里给出如何通过UTM安装ubuntu18.04-server的教程:
- 官网下载UTM
- 下载ubuntu18.04-server.iso
- 在UTM上新建虚拟机
- 设置内存与cpu,默认的内存比较小,建议拉大一点
- 在硬盘设置添加iso文件作为cd/dvd驱动,再添加一块nvme的硬盘,大小自选
- 启动虚拟机,根据传统安装步骤完成(大约要1小时,比x86原生慢不少)
- 安装完成后,在设置中移除iso驱动,然后就可以启动虚拟机了
安装完成后,这里也做了简单的性能测试。在R7-4800H的机器上(原生x86架构)virtualbox虚拟机ubuntu18server运行以下程序需要0.17s,在m1 pro(macbook pro 14乞丐版)上运行以下程序需要0.25s。虚拟机配置均为4G RAM,4核CPU。
#include <stdio.h>
//compile with -O0
int main()
for(int i=0;i<100000000;i++) ;
同样的配置,测浮点数,R7-4800H需要0.40s,m1 pro需要3.0s。性能损耗达到了650%
#include <stdio.h>
//compile with -O0
int main()
float k=0.000001;
for(int i=0;i<100000000;i++)
k*=1.000001;
运行速度只能说还能接受,由于现代的cpu足够快,大多数小程序感受不出运行速度的差距。这里还安装并测试了apache2,访问网页也十分流畅。
PS: 建议不要用UTM自带的UI和VM交互,不知道为何十分卡顿,建议通过ssh连接。
无法在苹果 m1 芯片中的颤振项目上执行 pod 安装
【中文标题】无法在苹果 m1 芯片中的颤振项目上执行 pod 安装【英文标题】:Can't perform pod install on flutter project in apple m1 chip 【发布时间】:2021-11-08 06:19:33 【问题描述】:我最近做了一个 Flutter 项目,并将该项目移到了我的带有 m1 芯片的新 mac mini 上。我已经成功安装了颤振、cocoapods、ffi 等,但是当我在项目的 ios 文件夹上运行 pod install 时,它会显示此错误,
46: from /usr/local/bin/pod:23:in `<main>'
45: from /usr/local/bin/pod:23:in `load'
44: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/bin/pod:55:in `<top (required)>'
43: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command.rb:52:in `run'
42: from /Users/ananthan/.gem/ruby/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
41: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/command/install.rb:52:in `run'
40: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer.rb:161:in `install!'
39: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer.rb:240:in `resolve_dependencies'
38: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/user_interface.rb:64:in `section'
37: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies'
36: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer.rb:416:in `analyze'
35: from /Library/Ruby/Gems/2.6.0/gems/earlgrey-1.16.0/lib/earlgrey/extensions/analyzer_extensions.rb:23:in `analyze'
34: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
33: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies'
32: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/user_interface.rb:64:in `section'
31: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:1077:in `block in resolve_dependencies'
30: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:177:in `sources'
29: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:177:in `map'
28: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/installer/analyzer.rb:178:in `block in sources'
27: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.0/lib/cocoapods/sources_manager.rb:22:in `find_or_create_source_with_url'
26: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:393:in `source_with_url'
25: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:60:in `all'
24: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:26:in `aggregate'
23: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:331:in `aggregate_with_repos'
22: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:331:in `map'
21: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:331:in `block in aggregate_with_repos'
20: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:322:in `source_from_path'
19: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:315:in `block in source_from_path'
18: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source/manager.rb:315:in `new'
17: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:30:in `initialize'
16: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/source.rb:31:in `initialize'
15: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:53:in `refresh_metadata'
14: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:338:in `download_file'
13: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:365:in `download_file_async'
12: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:372:in `download_and_save_with_retries_async'
11: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.11.0/lib/cocoapods-core/cdn_source.rb:440:in `download_typhoeus_impl_async'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
8: from /Users/ananthan/.gem/ruby/2.6.0/gems/typhoeus-1.4.0/lib/typhoeus.rb:2:in `<top (required)>'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
5: from /Users/ananthan/.gem/ruby/2.6.0/gems/ethon-0.14.0/lib/ethon.rb:3:in `<top (required)>'
4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2: from /Users/ananthan/.gem/ruby/2.6.0/gems/ffi-1.15.4/lib/ffi.rb:3:in `<top (required)>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- 2.6/ffi_c (LoadError)
谁能帮我解决这个问题。没有 pod install 项目将无法运行
【问题讨论】:
同样的问题 我尝试了所有方法,但找不到解决方案。 【参考方案1】:请按此步骤操作。
sudo arch -x86_64 gem install ffi
arch -x86_64 pod 安装
【讨论】:
我已经完成了,但仍然存在错误 我相信这个解决方案可以安装除 x86 二进制文件之外的所有内容。这样做后调试和构建项目是否有效?以上是关于苹果芯片(M1/Apple Chip)通过UTM安装x86架构虚拟机指南/性能测试(以ubuntu18.04为例)的主要内容,如果未能解决你的问题,请参考以下文章
电脑是苹果m1芯片的,安装的pd虚拟机 win 11 安装好后进入win 系统安装不了软件?
[从零开始学习FPGA编程-56]:视野篇-常见概念:chip(芯片)chipset(芯片组)chiplet(芯粒)die(裸片)的区别