MacOS M1 配置 Tensorflow 和 Pytorch

安装Pytorch参考这篇文章:https://zhuanlan.zhihu.com/p/522534035

有可能会报一个错:

 这个问题的原因是,pytorch版本过低,不支持,出现这个问题的原因是,conda安装的时候,可能会安装普通版,而不是nightly版本(安装后可以自己查看版本)。

解决方案是,去pytorch的官网:https://pytorch.org/get-started/locally/

然后复制下面生成的命令,就可以解决这个问题了 (MacOS 12.3+)

安装TensorFlow:

遇到的问题:

可能会报的第一个错:

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xd

说的是numpy版本过低,但conda查看,已经是最新的 1.23 了

这个问题我自己误打误撞找到了解决方案:

首先卸载numpy(不能用conda卸载,conda会自动把其余的一大堆东西一起卸载掉,会出现很多问题):pip uninstall numpy。然后如果这时输入 pip install numpy,会显示 numpy已经存在(不知道为什么),但版本是 1.19。这时候只需要 pip install --upgrade numpy,会更新到 1.23,这时就不会报错了。

第二个问题:AssertionError: Duplicate registrations for type 'optimizer'

解决方案是卸载掉 keras(同样是 pip ),然后就没有报错了

安装完成之后可能会有两个红色警告,但不影响运行

I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)

这个目前问题很普遍,但好像没有解决方法,论坛如下:

Could not identify NUMA node of pl… | Apple Developer Forums

猜你喜欢

转载自blog.csdn.net/qq_41934338/article/details/125695116