TensorFlow : インストール (GPU サポート)2018/01/29 |
機械学習ライブラリー, TensorFlow をインストールします。
コンピューターに搭載の NVIDIA GPU が使用できるようにセットアップします。
当例では以下の組み合わせでセットアップします。
⇒ TensorFlow 2.2, CUDA 10.1, cuDNN 7.6, Python 3.8
TensorFlow 公式のテスト済みのビルド構成は以下から確認可能です。
⇒ https://www.tensorflow.org/install/source?hl=en#gpu_support_2 |
|
[1] | |
[2] | |
[3] |
cuDNN (CUDA Deep Neural Network library) を NVIDIA 社のサイトからダウンロードしておきます。(ダウンロードにはアカウント登録が必要)
⇒ https://developer.nvidia.com/rdp/cudnn-download |
[4] | ダウンロードした cuDNN をサーバーにアップロードして、所定の場所へ配置しておきます。 |
[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] | その他必要なパッケージをインストールしておきます。 |
[root@dlp ~]# yum --enablerepo=centos-sclo-rh -y install rh-python38-python-devel gcc gcc-c++ make [root@dlp ~]# pip3 install virtualenv |
[6] | 任意の一般ユーザーでログインして、TensorFlow インストール用の Python 仮想環境を準備します。 TensorFlow をシステムワイドにインストールする場合は、当作業は不要で、root ユーザーで [7] を実行すれば OK です。 |
[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] | TensorFlow 2.2 をインストールします。 |
(venv) [cent@dlp ~]$
pip3 install --upgrade tensorflow==2.2.0
# 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) |
Sponsored Link |
|