我最近開始使用 Apple Silicon mac。我通過 Anaconda 安裝了 Tensorflow,版本 2.6.2,這是我能找到的最新版本。
當我運行訓練代碼時,訓練似乎開始初始化,直到遇到一些記憶體錯誤。然后它掛起,直到我手動停止它。
列印輸出如下所示:
(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 次嘗試),錯誤不會出現,據我所知,訓練正常進行,沒有問題。
我承認這里也有人問過類似的問題。但是,提供的唯一解決方案是確保我使用正確的解釋器和最新版本的 tensorflow。我正在使用 Python 3.9.7 和 TensorFlow 2.6.2,并且我確保我的程式也在使用這些版本。
是什么導致了這個問題?我愿意分享任何需要的資訊。
uj5u.com熱心網友回復:
在 Mac M1 上安裝 Tensorflow 真的很痛苦。我對你的問題的解決方法是重新安裝 Tensorflow;我遇到了和你一樣的問題,無法解決。首先,我假設您在 Monterey (Mac 12) 上;如果不是,則必須參考https://github.com/apple/tensorflow_macos/issues/153,這似乎對某些人有用。
如果這不起作用,請升級到 Monetery,然后按照此處列出的步驟操作:https : //developer.apple.com/metal/tensorflow-plugin/。這里是:
下載并安裝 Conda env [你可以從 https://github.com/conda-forge/miniforge#miniforge3 獲得它;下載“arm64 (Apple Silicon)”,因為你在 M1 上運行]:
chmod x ~/Downloads/Miniforge3-MacOSX-arm64.sh sh ~/Downloads/Miniforge3-MacOSX-arm64.sh source ~/miniforge3/bin/activate安裝 TensorFlow 依賴項:
conda install -c apple tensorflow-deps
然后安裝基礎 Tensorflow
python -m pip install tensorflow-macos
終于拿到了 Tensorflow Metal 插件
python -m pip install tensorflow-metal
Tensorflow 現在應該可以作業了(也可以使用 M1 GPU!)。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/396603.html
上一篇:服務訪問質量(QoS)
