TensorFlow对M1 Pro图执行错误



我试图使用金属加速tensorflow来训练我的Mac (OS版本13.1)上的模型,但当我调用。fit()时,我一直得到以下错误:

2023-01-07 22:12:03.348930: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x131289e10
2023-01-07 22:12:03.348967: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x131289e10
2023-01-07 22:12:03.405602: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x131289e10
2023-01-07 22:12:03.405631: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x131289e10
2023-01-07 22:12:03.405654: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x131289e10
Detected at node 'StatefulPartitionedCall_7' defined at (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/site-packages/ipykernel_launcher.py", line 17, in <module>
app.launch_new_instance()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/site-packages/traitlets/config/application.py", line 1041, in launch_instance
app.start()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 711, in start
self.io_loop.start()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/site-packages/tornado/platform/asyncio.py", line 215, in start
self.asyncio_loop.run_forever()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
self._run_once()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/asyncio/base_events.py", line 1899, in _run_once
handle._run()
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/asyncio/events.py", line 80, in _run
...
File "/opt/homebrew/Caskroom/miniforge/base/envs/ml/lib/python3.10/site-packages/keras/optimizers/optimizer_experimental/optimizer.py", line 1211, in apply_grad_to_update_var
return self._update_step_xla(grad, var, id(self._var_key(var)))
Node: 'StatefulPartitionedCall_7'
could not find registered platform with id: 0x131289e10
[[{{node StatefulPartitionedCall_7}}]] [Op:__inference_train_function_5916]

Python: 3.10.8TensorFlow: 2.11.0TensorFlow Metal: 0.70

如果我使用CPU进行训练,with tf.device('/CPU:0'):,一切都很好。

我正在使用miniconda,并尝试从头开始创建一个新环境,但我仍然得到相同的错误。

name: tf-metal
channels:
- apple
- conda-forge
dependencies:
- python
- pip
- tensorflow-deps
- ipykernel
- pip:
- tensorflow-macos
- tensorflow-metal  

我尝试更新到最新版本的tensorflow-metal和所有必需的依赖项,但问题仍然存在。

如果能帮助解决这个问题,我将不胜感激。谢谢你。

Python: 3.10.8 TensorFlow: 2.11.0 TensorFlow Metal: 0.70

你可能想检查这篇文章的回复,它建议安装tensorflow-macos v2.10.0和tensorflow-metal v0.6.0代替。

这个方法适合我:

python3 -m pip uninstall tensorflow-macos
python3 -m pip uninstall tensorflow-metal
python3 -m pip install tensorflow-macos==2.10.0
python3 -m pip install tensorflow-metal==0.6.0

相关内容

  • 没有找到相关文章