Mac M1 运行tensorflow2.x报错model: “0“ num_cores: 8 environment { key: “cpu_instruction_set“ value:

x33g5p2x  于2022-04-13 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(599)

报错信息如下:

2022-04-12 22:17:09.670204: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2022-04-12 22:17:09.673631: W tensorflow/core/platform/profile_utils/cpu_utils.cc:126] Failed to get CPU frequency: 0 Hz
2022-04-12 22:17:09.683158: F tensorflow/core/grappler/costs/op_level_cost_estimator.cc:710] Check failed: 0 < gflops (0 vs. 0)type: “CPU”
model: “0”
num_cores: 8
environment {
key: “cpu_instruction_set”
value: “ARM NEON”
}
environment {
key: “eigen”
value: “3.3.90”
}
l1_cache_size: 16384
l2_cache_size: 524288
l3_cache_size: 524288
memory_size: 268435456

看了很多文章,都是说新建一个.sh文件,复制以下内容即可解决

  1. #!/bin/bash
  2. set -e
  3. VERSION=0.1alpha3
  4. INSTALLER_PACKAGE=tensorflow_macos-$VERSION.tar.gz
  5. INSTALLER_PATH=https://github.com/apple/tensorflow_macos/releases/download/v$VERSION/$INSTALLER_PACKAGE
  6. INSTALLER_SCRIPT=install_venv.sh
  7. echo
  8. # Check to make sure we're good to go.
  9. if [[ $(uname) != Darwin ]] || [[ $(sw_vers -productName) != macOS ]] || [[ $(sw_vers -productVersion) != "11."* ]] ; then
  10. echo "ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later."
  11. exit 1
  12. fi
  13. # This
  14. echo "Installation script for pre-release tensorflow_macos $VERSION. Please visit https://github.com/apple/tensorflow_macos "
  15. echo "for instructions and license information."
  16. echo
  17. echo "This script will download tensorflow_macos $VERSION and needed binary dependencies, then install them into a new "
  18. echo "or existing Python 3.8 virtual environment."
  19. # Make sure the user knows what's going on.
  20. read -p 'Continue [y/N]? '
  21. if [[ ! $REPLY =~ ^[Yy]$ ]]
  22. then
  23. exit 1
  24. fi
  25. echo
  26. echo "Downloading installer."
  27. tmp_dir=$(mktemp -d)
  28. pushd $tmp_dir
  29. curl -LO $INSTALLER_PATH
  30. echo "Extracting installer."
  31. tar xf $INSTALLER_PACKAGE
  32. cd tensorflow_macos
  33. function graceful_error () {
  34. echo
  35. echo "Error running installation script with default options. Please fix the above errors and proceed by running "
  36. echo
  37. echo " $PWD/$INSTALLER_SCRIPT --prompt"
  38. echo
  39. echo
  40. exit 1
  41. }
  42. bash ./$INSTALLER_SCRIPT --prompt || graceful_error
  43. popd
  44. rm -rf $tmp_dir

(可是运行这个脚本的时候出现ERROR: TensorFlow with ML Compute acceleration is only available on macOS 11.0 and later.错误,然而自己的Mac版本都12.几了,还是报这个错误!

问题解决:

只需要终端执行pip安装即可!复制以下命令执行。

  1. pip install --upgrade --force --no-dependencies https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl

成功运行!!!

相关文章