1. primers

After the GPU version of the deep learning framework is successfully installed, check whether it is successfully installed. The GPU version is not as simple as the CPU version. Generally, the CPU version test only needs to import to test whether it can be imported correctly. The GPU version also needs to test whether CUDA or GPU modules can be called correctly.

The following will introduce the test methods of frameworks commonly used by the author, including TensorFlow, PyTorch, MXNet and PaddlePaddle. If you have other framework testing needs or experience, please let us know in the comments section. When necessary, the author will update in time.

  1. methods

1.0: TensorFlow

Tensorflow1. x and tensorFlow2. x test method is the same, the code is as follows:

print(tf.test.is_gpu_available())
Copy the code

The above code is saved as a.py file, which can be run using the test environment. Output: above is the log information, the key is the last True, indicating that the test is successful

The 2020-09-28 15:43:03. 197710: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not Compiled to Use: AVX2 2020-09-28 15:43:03.204525: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll Found device 0 with properties: I tensorflow/core/common_runtime/ GPU /gpu_device. Cc :1618] Found device 0 with properties: Name: GeForce RTX 2070 with max-Q Design Major: 7 Minor: 5 memoryClockRate(GHz): 1.125 2020-09-28 15:43:03.235352: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll The 2020-09-28 15:43:03. 242823: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll The 2020-09-28 15:43:03. 261932: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll The 2020-09-28 15:43:03. 268757: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll The 2020-09-28 15:43:03. 297478: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll The 2020-09-28 15:43:03. 315410: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll The 2020-09-28 15:43:03. 330562: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll Cc: 2020-09-28 15:43:03.332846: I Tensorflow /core/ COMMON_runtime/GPU /gpu_device.cc:1746] Adding Visible GPU Devices: 0 2020-09-28 15:43:05. 198465: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-09-28 15:43:05.200423: I tensorflow/ Core/COMMON_Runtime/GPU /gpu_device.cc: 220-09-28 15:43:05.201540: I TENsorflow/Core/GPU/Gpu_device.cc: 220-09-28 15:43:05.201540: I tensorflow/core/ COMMON_Runtime/GPU /gpu_device.cc:1178] 0: N 2020-09-28 15:43:05.203863: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/device:GPU:0 with 6306 MB memory) -> Physical GPU (Device :0, name: GeForce RTX 2070 with max-q Design, PCI bus ID: 0000:01:00.0, compute Capability: 7.5)Copy the code

The last True indicates that the test is successful. In fact, we can find a lot of GPU information

GPU model: Name: GeForce RTX 2070 with max-Q Design

Cuda version: Successfully Opened Dynamic Library CUDart64_100.dll (10.0)

Cudnn versions: Successfully Opened Dynamic Library CUDNn64_7.dll (7.x)

Number of Gpus: Adding Visible GPU Devices: 0 (1)

GPU: / Device :GPU:0 with 6306 MB memory (8G)

1.1: PyTorch

PyTorch and TensorFlow are similar in that they both have a GPU test interface. PyTorch’s GPU test code is as follows:

print(torch.cuda.is_available())
Copy the code

The above code is saved as a.py file and can be run using the test environment. The output: True indicates that the test is successful

True

Copy the code

You can see that the PyTorch output is much cleaner. The log output of TensorFlow is also controllable.

1.2: MXNet

MXNet differs from PyTorch and TensorFlow testing methods because MXNet’ has no GPU testing interface (or I could not find it). Therefore, the GPU test code of MXNet adopts try-catch method to test exceptions, and the code is as follows:

    _ = mx.nd.array(1,ctx=mx.gpu(0))
Copy the code

The above code is saved as a.py file and can be run using the test environment. The output: True indicates that the test is successful

1.3: PaddlePaddle

PaddlePaddle and TensorFlow test methods are similar in that both have GPU test interfaces. PyTorch’s GPU test code is as follows:

paddle.fluid.install_check.run_check()
Copy the code

The above code is saved as a.py file and can be run if the test environment is required. The output: Your Paddle Fluid Works well on MUTIPLE GPU or CPU., indicating that the test is successful

Running Verify Fluid Program ... W0928 16:23:17.825171 10572 Device_context. cc:252] Please NOTE: Device: 0, CUDA Capability: 75 Runtime API Version: 10.0 W0928 16:23:17.836141 10572 Device_context. cc:260] Device: 0, cuDNN Version: W0928 16:23:19.349067 10572 Build_strategy. Cc :170] Fusion_group is not enabled for Windows/MacOS now, and only effective when running with CUDA GPU. Your Paddle Fluid works well on MUTIPLE GPU or CPU. Your Paddle Fluid is installed successfully! Let's start deep Learning with Paddle Fluid nowCopy the code

1. Reference

1.0 :www.paddlepaddle.org.cn/install/qui…

Welcome to xiao Song’s official account ** “Minimalist AI” ** Take you to learn deep learning:

Based on the sharing of theoretical learning and application development technology of deep learning, the author will often share the dry contents of deep learning. When learning or applying deep learning, you can also communicate with me on this page if you have any questions.