Ubuntu 16.04 + CUDA toolkit 10.1 + cudNN7.6 + bazel 0.26.1及windows

Ubuntu 16.04 + CUDA toolkit 10.1 + cudNN7.6 + bazel 0.26.1

保證cuDNNCUDA SDK的版本一致即可.

從源碼編譯的話需要查看顯卡的計(jì)算能力,可在查看GPU計(jì)算能力垦搬,在配置的時(shí)候填入即可败匹,跟CUDA SDK的版本無(wú)關(guān)

▲必須注冊(cè)賬號(hào)后,才能選擇下載

▲記住上述幾個(gè)要點(diǎn), 以及最好先看下文章最后我的踩坑記錄隧饼,確保自己知道可能會(huì)有這些坑

▲.全程保持能連接外網(wǎng)(翻墻)

安裝NVIDIA驅(qū)動(dòng)

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n10" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> $ ubuntu-drivers devices # 查看

查看NVIDIA驅(qū)動(dòng)版本

$ sudo dpkg --list | grep nvidia-*</pre>

顯卡驅(qū)動(dòng)與CUDA版本對(duì)應(yīng)關(guān)系

最新的根據(jù)官網(wǎng)查看

image

下載NVIDIA驅(qū)動(dòng)

▲注意:得對(duì)應(yīng)匹配!!!

安裝完成后,可以通過(guò)nvidia-smi查看GPU使用情況

CUDA toolkit 10.1

安裝之前先看顯卡的驅(qū)動(dòng)版本

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n20" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> # 安裝過(guò)程
sudo dpkg -i cuda-repo-ubuntu1604-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb sudo apt update
$ sudo apt install cuda</pre>

設(shè)置環(huán)境變量

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n22" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> $ sudo vim ~/.bashrc

設(shè)置環(huán)境變量

export PATH=/usr/local/cuda-8.0/bin:PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:LD_LIBRARY_PATH

生效

$ source ~/.bashrc</pre>

驗(yàn)證安裝完成

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n24" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> nvcc -V cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make ./deviceQuery</pre>

△.如果顯示Result:PASS才是安裝成功干毅。這一步一定要保證錯(cuò)誤循未,不然之后bazel編譯時(shí)報(bào)錯(cuò)就很難分析問(wèn)題!2妗9宀健!璧眠!(只有在驅(qū)動(dòng)安裝好的情況下才能運(yùn)行成功,不然會(huì)報(bào)no CUDA-capable device is detected缩焦,或者GPU is lost)

如果失敗,卸載重裝

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n27" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> cd /usr/local/cuda/bin sudo ./uninstall_cuda_9.2.pl</pre>

安裝 Python 和 TensorFlow 軟件包依賴(lài)項(xiàng)

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n30" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> sudo apt install python-dev python-pip # or python3-dev python3-pip</pre>

安裝 TensorFlow pip 軟件包依賴(lài)項(xiàng)(如果使用虛擬環(huán)境,請(qǐng)省略 --user 參數(shù)):

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="bash" cid="n32" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> pip install -U --user pip six numpy wheel setuptools mock future>=0.17.1
pip install -U --user keras_applications==1.0.6 --no-deps
pip install -U --user keras_preprocessing==1.0.5 --no-deps</pre>

cudNN 7.6.3

選擇cuDNN Library for Linux

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n35" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> # 解壓cudNN
cp cudnn-8.0-linux-x64-v5.1.solitairetheme8 /usr/local/cuda/cudnn-8.0-linux-x64-v5.1.tgz cd /usr/local/cuda/
$ tar -xvf cudnn-8.0-linux-x64-v5.1.tgz
?
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*</pre>

Bazel

構(gòu)建Tensorflow需要用bazel,而wget下載很慢,需要代理,可以試著去github上下載后再傳到服務(wù)器

后來(lái)./configure配置TensorFlow時(shí),提示Bazel版本太高...(這個(gè)問(wèn)題出現(xiàn)在我下載的不是github下載下來(lái)的tensorflow责静,網(wǎng)盤(pán)下載的可能版本太低了)

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n40" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.29.1 installed.
Please downgrade your bazel installation to version 0.26.1 or lower to build TensorFlow! To downgrade: download the installer for the old version (from https://github.com/bazelbuild/bazel/releases) then run the installer.</pre>

從源碼構(gòu)建和安裝Tensorflow

第一次安裝的是2.0的版本

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="bash" cid="n44" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
(tf) apollo3d@apollo1:~/Downloads/tensorflow-master$ ./configure
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.26.0 installed.
Please specify the location of python. [Default is /home/apollo3d/tf/bin/python]: /usr/bin/python3
?
?
Found possible Python library paths:
/usr/local/lib/python3.5/dist-packages
/usr/lib/python3/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages]
?
Do you wish to build TensorFlow with XLA JIT support? [Y/n]:
XLA JIT support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]:
No OpenCL SYCL support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with ROCm support? [y/N]:
No ROCm support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with TensorRT support? [y/N]:
No TensorRT support will be enabled for TensorFlow.
?
Found CUDA 10.1 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
Found cuDNN 7 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
?
?
Please specify a list of comma-separated CUDA compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 3.5,7.0]: 5.0
?
?
Do you want to use clang as CUDA compiler? [y/N]: N
Clang will be used as CUDA compiler.
?
Do you wish to download a fresh release of clang? (Experimental) [y/N]: N
Clang will be downloaded and used to compile tensorflow.
?
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: --config=v2
?
?
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:
Not configuring the WORKSPACE for Android builds.
?
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
--config=mkl # Build with MKL support.
--config=monolithic # Config for mostly static monolithic build.
--config=ngraph # Build with Intel nGraph support.
--config=numa # Build with NUMA support.
--config=dynamic_kernels # (Experimental) Build kernels into separate shared objects.
--config=v2 # Build TensorFlow 2.x instead of 1.x.
Preconfigured Bazel build configs to DISABLE default on features:
--config=noaws # Disable AWS S3 filesystem support.
--config=nogcp # Disable GCP support.
--config=nohdfs # Disable HDFS support.
--config=nonccl # Disable NVIDIA NCCL support.
Configuration finished
</pre>

第二次1.14

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="bash" cid="n47" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> (pythonEnv) apollo3d@apollo1:~/Downloads/tensorflow$ ./configure
WARNING: Running Bazel server needs to be killed, because the startup options are different.
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.26.0 installed.
Please specify the location of python. [Default is /home/apollo3d/pythonEnv/bin/python]:
?
?
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'site' has no attribute 'getsitepackages'
Found possible Python library paths:
/home/apollo3d/pythonEnv/lib/python3.5/site-packages
Please input the desired Python library path to use. Default is [/home/apollo3d/pythonEnv/lib/python3.5/site-packages]
?
Do you wish to build TensorFlow with XLA JIT support? [Y/n]:
XLA JIT support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n
No OpenCL SYCL support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with ROCm support? [y/N]:
No ROCm support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.
?
Do you wish to build TensorFlow with TensorRT support? [y/N]:
No TensorRT support will be enabled for TensorFlow.
?
Found CUDA 10.1 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
Found cuDNN 7 in:
/usr/local/cuda/lib64
/usr/local/cuda/include
?
?
Please specify a list of comma-separated CUDA compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size, and that TensorFlow only supports compute capabilities >= 3.5 [Default is: 5.2]: 5.0
?
?
Do you want to use clang as CUDA compiler? [y/N]: n
nvcc will be used as CUDA compiler.
?
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
?
?
Do you wish to build TensorFlow with MPI support? [y/N]:
No MPI support will be enabled for TensorFlow.
?
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]:
?
?
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]:
Not configuring the WORKSPACE for Android builds.
?
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details.
--config=mkl # Build with MKL support.
--config=monolithic # Config for mostly static monolithic build.
--config=gdr # Build with GDR support.
--config=verbs # Build with libverbs support.
--config=ngraph # Build with Intel nGraph support.
--config=numa # Build with NUMA support.
--config=dynamic_kernels # (Experimental) Build kernels into separate shared objects.
Preconfigured Bazel build configs to DISABLE default on features:
--config=noaws # Disable AWS S3 filesystem support.
--config=nogcp # Disable GCP support.
--config=nohdfs # Disable HDFS support.
--config=noignite # Disable Apache Ignite support.
--config=nokafka # Disable Apache Kafka support.
--config=nonccl # Disable NVIDIA NCCL support.
Configuration finished
?
...
?
INFO: Elapsed time: 4826.834s, Critical Path: 298.31s
INFO: 24978 processes: 24978 local.
INFO: Build completed successfully, 26636 total actions

大概用了一個(gè)半小時(shí)</pre>

△.期間可能多次出現(xiàn)ERROR:[GET returned 404 Not Found, connect timed out],繼續(xù)重試即可

編譯 pip 軟件包

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="bash" cid="n51" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> (tf) apollo3d@apollo1:~/Downloads/tensorflow-master bazel build -c --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

-c 不鏈接直接編譯

Starting local Bazel server and connecting to it...
WARNING: The following configs were expanded more than once: [cuda_clang, using_cuda, download_clang_use_lld]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
WARNING: option '--crosstool_top' was expanded to from both option '--config=cuda_clang' (source /home/apollo3d/Downloads/tensorflow-master/.tf_configure.bazelrc) and option '--config=download_clang' (source /home/apollo3d/Downloads/tensorflow-master/.tf_configure.bazelrc)
?
$ bazel-bin/tensorfLow/tools/pip_package/build_pip_package ~/
tensorflow/bin # 傳入一個(gè)表示Python whell文件存儲(chǔ)路徑的參數(shù)
?

在虛擬環(huán)境打開(kāi)的情況下安裝</pre>

附錄:

windows上安裝cuda時(shí)一直顯示不能安裝袁滥,就是系統(tǒng)默認(rèn)安裝的版本太低了,或者根本就沒(méi)有安裝灾螃。只有到顯卡驅(qū)動(dòng)下載安裝了驅(qū)動(dòng)后题翻,才能正常安裝CUDA

▲正確安裝驅(qū)動(dòng)真的很重要!Q怼嵌赠!

windows安裝建議

安裝完linux后,我在自己筆記本上又安裝了個(gè)Windows10的塑荒,兩個(gè)是相通的,windows的很快我就安裝好了姜挺。主要卡殼的時(shí)間全都是浪費(fèi)在了驅(qū)動(dòng)版本安裝錯(cuò)誤齿税,只要把驅(qū)動(dòng)的版本弄對(duì)了。然后依次安裝NVIDIA驅(qū)動(dòng)初家、CUDA偎窘、Cudnn就可以了。

采坑記錄

▲下載tensorflow溜在,一定要從官網(wǎng)下載最新的陌知。千萬(wàn)不要去網(wǎng)盤(pán)上下載,我就是被這個(gè)坑了很久掖肋。最后從github下了后才逐漸正常仆葡。(github下載會(huì)很慢,可以見(jiàn)我的另外一篇文章志笼,如何提速)

./configure的配置也很重要沿盅,除了CUDA選項(xiàng)其他都選默認(rèn)

Linux系統(tǒng)下安裝TensorFlow的GPU版本

CUDA、顯卡驅(qū)動(dòng)和Tensorflow版本之間的對(duì)應(yīng)關(guān)系

Linux x86_64 Driver Version與CUDA Toolkit的對(duì)應(yīng)纫溃,一定要對(duì)應(yīng)好腰涧,CUDA超出了Driver Version的話,是無(wú)法使用的^提示

==>CUDA 10.1的需要Linux x86_64 Driver Version>=410.48紊浩。同時(shí)窖铡,tensorflow-gpu默認(rèn)安裝的是1.14版本,要求的cudNN為7坊谁,CUDA為9

google.xxxx.xxxx==>unknown hosts

報(bào)了這個(gè)錯(cuò)以后才發(fā)現(xiàn)费彼,服務(wù)器的DNS沒(méi)配置(云服務(wù)器一般不會(huì)出現(xiàn)這樣的問(wèn)題)

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n70" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> $ sudo vim /etc/resolv.conf

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

nameserver 8.8.8.8
nameserver 8.8.4.4
?</pre>

▲An error occurred during the fetch of repository 'llvm':Error 404 , cant connect

多次重試即可

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n75" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> (tf) apollo3d@apollo1:~/Downloads/tensorflow-master bazel build -c --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package</pre>

▲報(bào)錯(cuò) AttributeError: '_NamespacePath' object has no attribute 'sort'

重新安裝setuptools

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n79" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> (pythonEnv) pip uninstall setuptools (pythonEnv) pip install setuptools
(pythonEnv) $ pip install googleapis-common-protos</pre>

執(zhí)行上述命令需要相當(dāng)長(zhǎng)的一段時(shí)間口芍,具體時(shí)長(zhǎng)取決于你的計(jì)算機(jī)性能箍铲。

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n81" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> Target //tensorflow/tools/pip_package:build_pip_package up-to-date:
bazel-bin/tensorflow/tools/pip_package/build_pip_package
INFO: Elapsed time: 77.892s, Critical Path: 77.18s
INFO: 45 processes: 45 local.
INFO: Build completed successfully, 46 total actions
?</pre>

待Bazel成功完成上述任務(wù)后會(huì)輸出,運(yùn)行輸出的可執(zhí)行程序鬓椭,并傳入一個(gè)表示Python whee文件存儲(chǔ)路徑的參數(shù):

bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="" cid="n84" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> (pythonEnv) apollo3d@apollo1:~/Downloads/tensorflow$ bazel-bin/tensorflow/tools/pip_package/build_pip_package ~/
2019年 09月 24日 星期二 14:34:05 CST : === Preparing sources in dir: /tmp/tmp.pguTqrHuLA
~/Downloads/tensorflow ~/Downloads/tensorflow
~/Downloads/tensorflow
/tmp/tmp.pguTqrHuLA/tensorflow/include ~/Downloads/tensorflow
~/Downloads/tensorflow
2019年 09月 24日 星期二 14:34:11 CST : === Building wheel
warning: no files found matching '.pyd' under directory ''
warning: no files found matching '.pd' under directory ''
warning: no files found matching '.dylib' under directory ''
warning: no files found matching '.dll' under directory ''
warning: no files found matching '.lib' under directory ''
warning: no files found matching '.csv' under directory ''
warning: no files found matching '.h' under directory 'tensorflow_core/include/tensorflow'
warning: no files found matching '
' under directory 'tensorflow_core/include/third_party'
2019年 09月 24日 星期二 14:34:33 CST : === Output wheel file is in: /home/apollo3d/</pre>

pip安裝

上述命令將在~/tensorlowbn下創(chuàng)建一個(gè)Python.wh文件颠猴。請(qǐng)確保你的“tensor-fow Virtualenv不境處于活動(dòng)狀態(tài),然后用pip安裝該whee文件(請(qǐng)注意該二進(jìn)制文件的具體名稱(chēng)會(huì)依所安裝的TensorFlow版本小染、所使用的操作系統(tǒng)和Python版本而不同):

(pythonEnv) apollo3d@apollo1:~$ pip install tensorflow-2.0.0rc2-cp35-cp35m-linux_x86_64.whl

▲安裝成功后翘瓮,使用時(shí)報(bào)錯(cuò)

使用TensorFlow時(shí)報(bào)錯(cuò)FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy.......

報(bào)錯(cuò)原因:numpy1-17-0版本過(guò)高,使用numpy-1.16-0版本即可

解決方法:重新安裝numpy-1.16-0

<pre spellcheck="false" class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" lang="shell" cid="n93" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 0px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> pip uninstall numpy pip install numpy==1.16.0</pre>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末氧映,一起剝皮案震驚了整個(gè)濱河市春畔,隨后出現(xiàn)的幾起案子脱货,更是在濱河造成了極大的恐慌岛都,老刑警劉巖律姨,帶你破解...
    沈念sama閱讀 217,657評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異臼疫,居然都是意外死亡择份,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,889評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門(mén)烫堤,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)荣赶,“玉大人,你說(shuō)我怎么就攤上這事鸽斟“未矗” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 164,057評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵富蓄,是天一觀的道長(zhǎng)剩燥。 經(jīng)常有香客問(wèn)我,道長(zhǎng)立倍,這世上最難降的妖魔是什么灭红? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,509評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮口注,結(jié)果婚禮上变擒,老公的妹妹穿的比我還像新娘。我一直安慰自己寝志,他們只是感情好娇斑,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,562評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著澈段,像睡著了一般悠菜。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上败富,一...
    開(kāi)封第一講書(shū)人閱讀 51,443評(píng)論 1 302
  • 那天悔醋,我揣著相機(jī)與錄音,去河邊找鬼兽叮。 笑死芬骄,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的鹦聪。 我是一名探鬼主播账阻,決...
    沈念sama閱讀 40,251評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼泽本!你這毒婦竟也來(lái)了淘太?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 39,129評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎蒲牧,沒(méi)想到半個(gè)月后撇贺,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,561評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡冰抢,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,779評(píng)論 3 335
  • 正文 我和宋清朗相戀三年松嘶,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片挎扰。...
    茶點(diǎn)故事閱讀 39,902評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡翠订,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出遵倦,到底是詐尸還是另有隱情尽超,我是刑警寧澤,帶...
    沈念sama閱讀 35,621評(píng)論 5 345
  • 正文 年R本政府宣布梧躺,位于F島的核電站橙弱,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏燥狰。R本人自食惡果不足惜棘脐,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,220評(píng)論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望龙致。 院中可真熱鬧蛀缝,春花似錦、人聲如沸目代。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,838評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)榛了。三九已至在讶,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間霜大,已是汗流浹背构哺。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,971評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留战坤,地道東北人曙强。 一個(gè)月前我還...
    沈念sama閱讀 48,025評(píng)論 2 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像途茫,于是被迫代替她去往敵國(guó)和親碟嘴。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,843評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容