我最近开始使用苹果的硅mac。我通过Anaconda 2.6.2版本安装了Tensorflow,这是我能找到的最新版本。
当我运行培训代码时,培训似乎开始初始化,直到达到某个内存错误。然后挂起直到我手动停止。
打印的输出结果如下:
(machine_learning) eric@mac-mini cr_battle_predictor % python3 main.py
2021-12-25 22:11:24.286059: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
0%| | 0/350 [00:00<?, ?epoch/s]2021-12-25 22:11:24.368779: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)
python3(48188,0x304135000) malloc: Incorrect checksum for freed object 0x7fe41cac4e80: probably modified after being freed.
Corrupt value: 0x7fe42c07e480
python3(48188,0x304135000) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort python3 main.py
(machine_learning) eric@mac-mini cr_battle_predictor % /Users/eric/.conda/envs/machine_learning/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
由于某些原因,非常偶尔(大约1/7次尝试),错误没有出现,据我所知,训练进展正常,没有问题。
我承认这是一个similar problem has been asked here。然而,提供的唯一解决方案是确保我使用的是正确的解释器,以及最新版本的tensorflow。我正在使用Python3.9.7和TensorFlow 2.6.2,并确保我的程序也使用了这些版本。
是什么导致了这个问题?我愿意分享任何需要的信息。
发布于 2021-12-27 21:18:36
在Mac M1上安装Tensorflow是一个真正的痛苦。我对您的问题的解决方案是重新安装Tensorflow;我面临与您相同的问题,无法修复它。首先,我将假设您在蒙特雷(Mac 12)上;如果不是,您将不得不引用https://github.com/apple/tensorflow_macos/issues/153,它似乎对某些人有效。
如果这不起作用,升级到货币化,然后按照这里概述的步骤:https://developer.apple.com/metal/tensorflow-plugin/。下面是:
https://github.com/conda-forge/miniforge#miniforge3;下载并安装Conda您可以从
下载"arm64 (苹果硅)“获得这一点,因为您在M1上运行:
chmod +x ~/下载/MINIMAX3-MacOSX-arm64.sh~/下载/MINIMAX3-MacOSX-arm64.sh源~/miniforge3 3/bin/activate
安装TensorFlow依赖项:
conda安装-c苹果tensorflow-deps
然后安装基本的Tensorflow
python -m pip安装tensorflow-macos
最后得到Tensorflow金属插件
python -m pip安装tensorflow金属
Tensorflow现在应该可以工作了(也可以使用M1 GPU!)。
https://stackoverflow.com/questions/70484019
复制相似问题