CentOS 7
Sponsored Link

TensorFlow : Install (GPU Support)2018/01/29

 
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 ~]#
yum --enablerepo=centos-sclo-rh -y install rh-python38-python-devel gcc gcc-c++ make

[root@dlp ~]#
pip3 install virtualenv

[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 ~]$
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-23 20:48:06.201986: 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-23 20:48:06.202995: 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-23 20:48:06.203876: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-07-23 20:48:06.211783: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-07-23 20:48:06.216976: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-07-23 20:48:06.220178: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-07-23 20:48:06.228212: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-07-23 20:48:06.231809: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-07-23 20:48:06.248708: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2020-07-23 20:48:06.249095: 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-23 20:48:06.258119: 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-23 20:48:06.258725: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-07-23 20:48:06.272872: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2801655000 Hz
2020-07-23 20:48:06.273370: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x3e3c5e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-07-23 20:48:06.273470: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-07-23 20:48:06.338098: 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-23 20:48:06.338930: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x3e50680 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-07-23 20:48:06.339182: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): GeForce GTX 1070, Compute Capability 6.1
2020-07-23 20:48:06.339678: 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-23 20:48:06.340351: 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-23 20:48:06.340522: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-07-23 20:48:06.340715: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-07-23 20:48:06.340918: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-07-23 20:48:06.341135: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-07-23 20:48:06.341350: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-07-23 20:48:06.341575: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-07-23 20:48:06.342015: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2020-07-23 20:48:06.342273: 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-23 20:48:06.342990: 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-23 20:48:06.343529: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
2020-07-23 20:48:06.343740: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-07-23 20:48:06.345055: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-07-23 20:48:06.345123: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1108]      0
2020-07-23 20:48:06.345339: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1121] 0:   N
2020-07-23 20:48:06.345726: 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-23 20:48:06.346557: 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-23 20:48:06.347197: 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(687.792, shape=(), dtype=float32)
Matched Content