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

macos安装metal 加速版 pytorch


categories: [Python]
tags: Python MacOS

写在前面

试试 m3 的 metal 加速效果如何

  • Mac computers with Apple silicon or AMD GPUs
  • macOS 12.3 or later
  • Python 3.7 or later
  • Xcode command-line tools: xcode-select --install

安装 Python: conda-forge

brew install miniforge

镜像

channels:- defaults
show_channel_urls: true
auto_activate_base: false
ssl-verify: false
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmsys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudbioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmenpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudsimpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/clouddeepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

安装

开一个新的虚拟环境, 这个是重点, 如果不开的话, 原有的环境会污染 C 库的链接, 所以这一步是必须的

On Mac OS X, import numpy complaining about “Library not loaded: @rpath/libgfortran.3.dylib” · Issue #12970 · numpy/numpy;

这个方案不彻底, 直接卸载 numpy 然后重装不能解决问题…

conda create -n py3xi python=3.11
conda activate py3xi
# conda update --all -c conda-forge # optional
# 重点: 
conda install pytorch torchvision torchaudio -c pytorch-nightly 

然后测试

Accelerated PyTorch training on Mac - Metal - Apple Developer;

import torch
if torch.backends.mps.is_available():mps_device = torch.device("mps")x = torch.ones(1, device=mps_device)print (x)
else:print ("MPS device not found.")
'''
tensor([1.], device='mps:0')
'''

可以在 MacOS 上跑深度学习了.

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

相关文章:

  • 【学习笔记】lyndon分解
  • 21、命令执行
  • Qexo博客后台管理部署
  • 最小生成树prim
  • 实用篇 | 一文学会人工智能中API的Flask编写(内含模板)
  • Si24R03—低功耗 SOC 芯片(集成RISC-V内核+2.4GHz无线收发器)
  • C# Winform 日志系统
  • 【Java 基础】27 XML 解析
  • 地图服务 ArcGIS API for JavaScript基础用法全解析
  • docker学习(八、mysql8.2主从复制遇到的问题)
  • React-hook-form-mui(三):表单验证
  • 【私域运营秘籍】4大用户调研方法,让你轻松掌握用户心理!
  • 2.8寸 ILI9341 TFTLCD 学习移植到STM32F103C8T6
  • Java利用TCP实现简单的双人聊天
  • 软件压力测试的重要性与用途
  • 【数据挖掘】国科大苏桂平老师数据库新技术课程作业 —— 第二次作业
  • Qt + MySQL(简单的增删改查)
  • postgresql设置免密登录
  • 视频汇聚/音视频流媒体视频平台/视频监控EasyCVR分享页面无法播放,该如何解决?
  • 机器学习-逻辑回归
  • Edge调用Aria2下载
  • 解密QQ号——C语言
  • 三、jvm中的对象及引用
  • Docker网络架构介绍
  • Android studio新版本aar包导入项目中配置
  • HBase-架构与设计
  • SpringBoot基础系列:工具类使用
  • 使用 nohup java - jar 不输出日志
  • 前端开发学习 (五) 生命周期函数、Ajax请求
  • TypeScript中的单件设计模式