本文记录自己使用MacBook 13inch early2015+技嘉GTX1080 Gaming Box配置深度学习环境的过程
安装eGPU(待添加)
1.安装PyTorch(待添加)
1.安装tensorflow
- 下载tensorflow-1.5.0源码
- (修改文件)删除三个文件中的“__align__ (sizeof(T))”代码语句
- tensorflow/core/kernels/depthwise_conv_op_gpu.cu.cc
- tensorflow/core/kernels/split_lib_gpu.cu.cc
- tensorflow/core/kernels/concat_lib_gpu.impl.cu.cc
- (参考)
- https://github.com/tensorflow/tensorflow/issues/14174
- https://gist.github.com/smitshilu/53cf9ff0fd6cdb64cca69a7e2827ed0f
- 安装tf前准备
- sudo pip install six numpy wheel(Anaconda中已包含)
- brew install coreutils
- 因为已经安装了最新的Xcode9,CLT命令行工具版本太新,不支持cuda9,需要重新安装Command_Line_Tools_macOS_10.12_for_Xcode_8.2.dmg,并运行sudo xcode-select --switch /Library/Developer/CommandLineTools,之后可以运行clang --version查看命令行工具版本
- 参考)
- https://github.com/pytorch/pytorch/issues/3047
- 配置tensorflow安装信息
- $ cd tensorflow # cd to the top-level directory created
- $ ./configure
- 补充步骤(不确定是否必要,最后一次尝试编译安装并成功,使用了以下部分代码)
- bazel clean --expunge
- 参考中包含完整的5行命令(我只是用了一行):
- bazel clean --expunge
- sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
- sudo xcodebuild -license
- bazel clean --expunge
- bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package(开始编译)
- (参考)
- https://stackoverflow.com/questions/45276830/xcode-version-must-be-specified-to-use-an-apple-crosstool
- 编译安装tf1.5
- $ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
- $ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
- $ sudo pip install /tmp/tensorflow_pkg/tensorflow-1.5.0-py2-none-any.whl
- (参考)
- https://www.tensorflow.org/install/install_sources
- 中间遇到的报错信息
- 问题:Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so’ failed
- 解决办法:(修改文件)删除tensorflow/third_party/gpus/cuda/BUILD.tpl.文件中的linkopts = ["-lgomp"],
- (参考)https://github.com/tensorflow/tensorflow/issues/15172
- 问题:运行tensorflow测试程序出现OOM错误
- 解决办法:
- gpu_options = tf.GPUOptions(allow_growth=True)
- with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
- (参考)https://stackoverflow.com/questions/39465503/cuda-error-out-of-memory-in-tensorflow
- 解决办法:
- 问题:Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so’ failed