TensorFlow : Install (GPU Support)2020/07/23 |
Install TensorFlow which is the Machine Learning Library.
On this example, Setup TensorFlow to use NVIDIA GPU on your computer.
This example is based on the build configurations like follows.
⇒ TensorFlow 2.2, CUDA 10.1, cuDNN 7.6, Python 3.8
You can see Tested build configurations on the site below.
⇒ https://www.tensorflow.org/install/source?hl=en#gpu_support_2 |
|
[1] | |
[2] | |
[3] |
Download cuDNN (CUDA Deep Neural Network library) from the NVIDIA official site. (it needs to register a developer account)
⇒ https://developer.nvidia.com/rdp/cudnn-download |
[4] | Upload cuDNN to your Server and locate files like follows. |
[root@dlp ~]# tar zxvf cudnn-10.1-linux-x64-v7.6.5.32.tgz [root@dlp ~]# cp ./cuda/include/cudnn.h /usr/local/cuda-10.1/include/ [root@dlp ~]# cp -a ./cuda/lib64/libcudnn* /usr/local/cuda-10.1/lib64/ [root@dlp ~]# ldconfig [root@dlp ~]# echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/extras/CUPTI/lib64' >> /etc/profile.d/cuda101.sh [root@dlp ~]# source /etc/profile.d/cuda101.sh |
[5] | Install other required packages. |
[root@dlp ~]# dnf -y install python38-devel python3-virtualenv gcc gcc-c++ make
|
[6] | Login as a common user and prepare Python virtual environment to install TensorFlow. If you'd like to install it on System Wide, skip this section and execute the next [7] with root user account. |
[cent@dlp ~]$ /usr/bin/py3-virtualenv --system-site-packages -p python3 ./venv Running virtualenv with interpreter /usr/bin/python3 Using base prefix '/usr' /usr/lib/python3.6/site-packages/virtualenv.py:1043: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp New python executable in /home/cent/venv/bin/python3 Also creating executable in /home/cent/venv/bin/python Installing setuptools, pip, wheel...done.[cent@dlp ~]$ source ./venv/bin/activate (venv) [cent@dlp ~]$ |
[7] | Install TensorFlow 2.2. |
(venv) [cent@dlp ~]$
pip3 install --upgrade tensorflow==2.2.0
# verify to run TensorFlow (venv) [cent@dlp ~]$ python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))" 2020-07-22 19:32:14.249439: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1 2020-07-22 19:32:14.550135: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.553826: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: pciBusID: 0000:05:00.0 name: GeForce GTX 1070 computeCapability: 6.1 coreClock: 1.7845GHz coreCount: 15 deviceMemorySize: 7.93GiB deviceMemoryBandwidth: 238.66GiB/s 2020-07-22 19:32:14.558365: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1 2020-07-22 19:32:14.569762: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10 2020-07-22 19:32:14.577865: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10 2020-07-22 19:32:14.585534: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10 2020-07-22 19:32:14.596212: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10 2020-07-22 19:32:14.602357: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10 2020-07-22 19:32:14.623688: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7 2020-07-22 19:32:14.625668: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.629147: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.632464: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0 2020-07-22 19:32:14.646382: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2801715000 Hz 2020-07-22 19:32:14.648402: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7f259c000b60 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-07-22 19:32:14.650661: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version 2020-07-22 19:32:14.761719: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.764389: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55aac35432f0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices: 2020-07-22 19:32:14.766704: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce GTX 1070, Compute Capability 6.1 2020-07-22 19:32:14.768802: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.771914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties: pciBusID: 0000:05:00.0 name: GeForce GTX 1070 computeCapability: 6.1 coreClock: 1.7845GHz coreCount: 15 deviceMemorySize: 7.93GiB deviceMemoryBandwidth: 238.66GiB/s 2020-07-22 19:32:14.775533: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1 2020-07-22 19:32:14.777365: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10 2020-07-22 19:32:14.779119: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10 2020-07-22 19:32:14.780878: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10 2020-07-22 19:32:14.782656: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10 2020-07-22 19:32:14.784453: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10 2020-07-22 19:32:14.786275: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7 2020-07-22 19:32:14.788071: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.791508: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.794860: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0 2020-07-22 19:32:14.796393: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1 2020-07-22 19:32:14.799452: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-07-22 19:32:14.801291: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108] 0 2020-07-22 19:32:14.802473: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0: N 2020-07-22 19:32:14.803807: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.807194: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2020-07-22 19:32:14.810579: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1247] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7554 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:05:00.0, compute capability: 6.1) tf.Tensor(942.073, shape=(), dtype=float32) |
Sponsored Link |