Use the GPU version of tensorflow-1.14.0 to train the data set in colab

When I was running a face recognition project, after I configured cuda9.0 and cudnn on my laptop, it still couldn’t run. The reason was that this code could not run on Windows system, so I tried to clone on Google Drive. I tried the source code on GitHub, thinking that I would also download the cuda9.0 corresponding to the computer version, and found that I kept reporting errors, prompting libcudart.so.9.0:cannot open shared object file. Finally, I found out that Google Drive comes with cuda10.1. The code viewed is as follows:

!cat /usr/local/cuda/version.txt
# 输出:CUDA Version 10.1.243

Then I thought I should still match the computer, so I downgraded cuda to version 9.0, the code is as follows:

!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
!apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
!apt-get update
!apt-get install cuda=9.0.176-1

Then I installed the gpu version of tensorflow==1.14.0 according to the installation requirements on GitHub (you need to change the notebook setting to gpu mode when installing on colab, otherwise an error will be reported, as if it is a built-in attribute), and found An error:

MXNetError: [01:23:15] src/operator/nn/./cudnn/cudnn_convolution-inl.h:155: Check failed: e == CUDNN_STATUS_SUCCESS (8 vs. 0) : cuDNN: CUDNN_STATUS_EXECUTION_FAILED 

Then I went to query and found that the gpu version of tensorflow needs some support, as stated on the tensorflow official website :

TensorFlow GPU support requires various drivers and libraries. To simplify installation and avoid library conflicts, it is recommended that you use a GPU-enabled TensorFlow Docker image (Linux only). This setting only requires the  NVIDIA® GPU driver .

Then click on the link and you will find the following picture:

So, I should modify it now and downgrade cuda to version 10.0, because it seems that some people say that version 1.14.0 of tensorflow should match cuda10.0, otherwise there is a risk of error.

Alright! Sure enough, the version should correspond. I downgraded cuda to 10.0 because of the code of this big guy. Please move: https://www.stacknoob.com/s/nTWgcgsnykxDbgTq7XfsV2 . Then remember to update to the version of cuda=10.0 when downloading mxnet.

!pip install mxnet-cu100
import mxnet as mx  

Generally, you can try import after installation, and continue to change if an error is reported, otherwise the final code will be stuck.

Let me show you the final output result, which is the image quality of two faces:

So excited! Hahahaha.

Guess you like

Origin blog.csdn.net/weixin_44987948/article/details/109090719