As the network becomes more and more complex and the training becomes more and more difficult, GPU can be used for learning if conditions permit. This article describes how to use tensorflow in a GPU environment NET.
TensorFlow.NET using GPU is very simple. The code does not need to be modified. You can replace a dependent library. Whether the program can run successfully mainly depends on whether the environment is installed correctly. This article focuses on the installation of the environment.
CUDA and cuDNN are easy to install. The key is to install the correct version.
1. Confirm installation version
First, the computer must have an NVIDIA graphics card!
Right click on the desktop, select NVIDIA control panel, and click system information in the lower left corner of the program.
First, confirm the CUDA version of the graphics card. Mine is 10.1. It should be installed according to your own environment.
According to the CUDA version of the graphics card, you need to install the corresponding CUDA Toolkit and cuDNN package, and also reference the tensorflow of the corresponding version_ GPU runtime.
This is a corresponding relationship provided by TensorFlow's official website.
2. Install CUDA Toolkit
Installation package download address: CUDA Toolkit 11.5 Update 1 Downloads | NVIDIA Developer
Due to indescribable reasons, the website opens very slowly and needs some patience.
The program I downloaded is cuda_10.1.243_win10_network.exe, to ensure that the first two version numbers are consistent with the CUDA version of the local graphics card, the last one has little impact.
As long as you select the right version, there will be no problem with the installation. You can basically go all the way to the next step.
3. Install cuDNN
Search cuDNN on NVIDIA website to find the download address. Also pay attention to the version.
The file I downloaded is cudnn-10.1-windows10-x64-v8 0.5. 39.zip
It can be seen from the file name that the software version is 8.0 and the corresponding CUDA version is 10.1. This is not completely consistent with what is said on TensonFlow website, but it can be used in actual measurement.
Note that cuDNN software does not need to be installed, just unzip it to the specified directory.
Suppose the CUDA installation directory is C: \ program files \ NVIDIA GPU computing toolkit \ CUDA \ v10 one
The extracted files include three folders: bin, include and lib, and can be combined with three folders with the same name under the CUDA installation directory.
[I doubt that you can unzip it anywhere. Just add the path to the path, but I haven't tested it.]
4. Replace dependent Libraries
The first part of this series introduced a tensorflow. Net project's dependency library is as follows:
If GPU learning is required, change one of the libraries as follows.
Note the version of the runtime. My GPU supports up to 2.3
If your running environment is not available at this time, a warning will pop up when the program runs and automatically switch to the CPU for calculation.
5. Debug
If the environment is not installed successfully, the program will print the following information:
2021-08-29 09:46:26.631756: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-08-29 09:46:26.633225: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2021-08-29 09:46:27.323608: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-08-29 09:46:27.993386: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-08-29 09:46:27.994493: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found 2021-08-29 09:46:27.997410: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found 2021-08-29 09:46:27.998498: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found 2021-08-29 09:46:27.999403: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found 2021-08-29 09:46:28.000402: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found 2021-08-29 09:46:28.001807: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found 2021-08-29 09:46:28.001917: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices...
Keyword: Could not load dynamic library
If the environment installation is successful, the following is displayed:
2021-08-29 09:46:26.631756: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-08-29 09:46:26.633225: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2021-08-29 09:46:27.323608: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-08-29 09:46:27.993386: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2021-08-29 09:46:27.994493: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found 2021-08-29 09:46:27.997410: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cufft64_10.dll'; dlerror: cufft64_10.dll not found 2021-08-29 09:46:27.998498: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'curand64_10.dll'; dlerror: curand64_10.dll not found 2021-08-29 09:46:27.999403: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found 2021-08-29 09:46:28.000402: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found 2021-08-29 09:46:28.001807: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found 2021-08-29 09:46:28.001917: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices...
Keywords: Successfully opened dynamic library
[related resources]
Source code: Git: https://gitee.com/seabluescn/tf_not.git
catalog: View tensorflow Net machine learning introduction series directory