編譯安裝tensorflow1.12.2

環境:

1) os

16.04.1-Ubuntu

2)cpu有點年頭了

# cat /proc/cpuinfo | grep "model name"
model name    : AMD Athlon(tm) II X2 250 Processor
model name    : AMD Athlon(tm) II X2 250 Processor

3)cuda

nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148

 

步驟:

1) cuda 卸載:

/usr/local/cuda/bin/*uninstall*

2) nvidia驅動卸載

/usr/bin/nvidia-uninstall

cuda安裝包自帶驅動,無需另外安裝

3) 安裝cuda前記得禁用nouveau

ubuntu自帶的nouveau驅動會影響cuda安裝

lsmod | grep nouveau
若有輸出,則
cd /etc/modprobe.d
sudo touch blacklist-nouveau.conf
sudo gedit blacklist-nouveau.conf
在打開的文件中輸入
blacklist nouveau  
options nouveau modeset=0 
保存退出,然後
sudo update-initramfs -u
一定要重啓,再用終端檢測一下,按ctrl+alt+f1切換到終端,登錄,init 3 切換到文本模式
lsmod | grep nouveau

4)cuda安裝, 文本模式下安裝
cuda_9.2.148_396.37_linux.run
記得不要安裝opengl,

5)設置環境變量

sudo gedit /etc/profile
末尾添加:
export PATH=/usr/local/cuda-9.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
nvcc --version 查看cuda版本

6)cudnn安裝
用deb文件安裝(失敗)
應當下載tgz文件,解壓縮

7) 現成的 tensorflow whl安裝文件(失敗,原因是sse4.1不支持)
https://pypi.org/project/tensorflow-gpu/1.12.2/#files

8) 安裝python3.6
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo apt-get install python3.6-dev
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1 
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

原文:https://blog.csdn.net/gangzhucoll/article/details/81294236 
9) 下載Tensorflow源文件,並切換到v1.12.2版本
10) bazel 從源碼編譯
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package 
必須安裝 bazel 1.18.1, 最新的2.4.1是不能用的
I got the same error in building tensorflow r1.9 for one older Nvidia
 GPU card. I downgraded the bazel from 0.19.1 to 0.18.1. The error was 
fixed in compiling.

還是要設置bazel的代理的,否則下載依賴包出錯
export HTTP_PROXY=http://127.0.0.1:8118
export HTTPS_PROXY=http://127.0.0.1:8118

https://gist.github.com/Brainiarc7/6d6c3f23ea057775b72c52817759b25c

11)得到whl文件,安裝成功


 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章