Difference between revisions of "Tensorflow with gpu"
From ElphelWiki
(Created page with "==Pre== * check device ~$ lspci | grep NVIDIA 81:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1) 81:00.1 Audio device: NVIDIA Corporation...") |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
81:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1) | 81:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1) | ||
* check driver version | * check driver version | ||
− | ~$ | + | ~$ cat /proc/driver/nvidia/version |
+ | NVRM version: NVIDIA UNIX x86_64 Kernel Module 387.26 Thu Nov 2 21:20:16 PDT 2017 | ||
+ | GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) | ||
* install cuda 9.0 with patches | * install cuda 9.0 with patches | ||
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal | https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal | ||
Line 15: | Line 17: | ||
~$ export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} | ~$ export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} | ||
~$ export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} | ~$ export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} | ||
+ | * | ||
+ | ~$ nvidia-smi | ||
+ | Thu Apr 26 12:39:25 2018 | ||
+ | +-----------------------------------------------------------------------------+ | ||
+ | | NVIDIA-SMI 387.26 Driver Version: 387.26 | | ||
+ | |-------------------------------+----------------------+----------------------+ | ||
+ | | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | ||
+ | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | ||
+ | |===============================+======================+======================| | ||
+ | | 0 GeForce GT 610 Off | 00000000:81:00.0 N/A | N/A | | ||
+ | | N/A 31C P8 N/A / N/A | 148MiB / 956MiB | N/A Default | | ||
+ | +-------------------------------+----------------------+----------------------+ | ||
+ | |||
+ | +-----------------------------------------------------------------------------+ | ||
+ | | Processes: GPU Memory | | ||
+ | | GPU PID Type Process name Usage | | ||
+ | |=============================================================================| | ||
+ | | 0 Not Supported | | ||
+ | +-----------------------------------------------------------------------------+ | ||
+ | |||
+ | * install tensorflow | ||
+ | ~$ sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl | ||
+ | |||
+ | * testing | ||
+ | ~$ python3 | ||
+ | Python 3.5.2 (default, Nov 23 2017, 16:37:01) | ||
+ | [GCC 5.4.0 20160609] on linux | ||
+ | Type "help", "copyright", "credits" or "license" for more information. | ||
+ | >>> | ||
+ | >>> | ||
+ | >>> | ||
+ | >>> import tensorflow as tf | ||
+ | >>> hello = tf.constant('Hello, World!') | ||
+ | >>> sess = tf.Session() | ||
+ | 2018-04-26 13:00:19.050625: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA | ||
+ | 2018-04-26 13:00:19.181581: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: | ||
+ | name: GeForce GT 610 major: 2 minor: 1 memoryClockRate(GHz): 1.62 | ||
+ | pciBusID: 0000:81:00.0 | ||
+ | totalMemory: 956.50MiB freeMemory: 631.69MiB | ||
+ | <font color='red'><b>2018-04-26 13:00:19.181648: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1394] Ignoring visible gpu device (device: 0, name: GeForce GT 610, pci bus id: 0000:81:00.0, compute capability: 2.1) with Cuda compute capability 2.1. The minimum required Cuda capability is 3.5.</b></font> | ||
+ | 2018-04-26 13:00:19.181669: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: | ||
+ | 2018-04-26 13:00:19.181683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917] 0 | ||
+ | 2018-04-26 13:00:19.181695: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0: N | ||
+ | >>> print(sess.run(hello)) | ||
+ | b'Hello, World!' | ||
+ | |||
+ | * Supported cards: | ||
+ | https://developer.nvidia.com/cuda-gpus |
Revision as of 11:49, 26 April 2018
Pre
- check device
~$ lspci | grep NVIDIA 81:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1) 81:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
- check driver version
~$ cat /proc/driver/nvidia/version NVRM version: NVIDIA UNIX x86_64 Kernel Module 387.26 Thu Nov 2 21:20:16 PDT 2017 GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
- install cuda 9.0 with patches
https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal
- then
sudo apt-get install cuda-9-0
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions
~$ export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}} ~$ export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
~$ nvidia-smi Thu Apr 26 12:39:25 2018 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 387.26 Driver Version: 387.26 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GT 610 Off | 00000000:81:00.0 N/A | N/A | | N/A 31C P8 N/A / N/A | 148MiB / 956MiB | N/A Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 Not Supported | +-----------------------------------------------------------------------------+
- install tensorflow
~$ sudo pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl
- testing
~$ python3 Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> >>> import tensorflow as tf >>> hello = tf.constant('Hello, World!') >>> sess = tf.Session() 2018-04-26 13:00:19.050625: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2018-04-26 13:00:19.181581: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: name: GeForce GT 610 major: 2 minor: 1 memoryClockRate(GHz): 1.62 pciBusID: 0000:81:00.0 totalMemory: 956.50MiB freeMemory: 631.69MiB 2018-04-26 13:00:19.181648: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1394] Ignoring visible gpu device (device: 0, name: GeForce GT 610, pci bus id: 0000:81:00.0, compute capability: 2.1) with Cuda compute capability 2.1. The minimum required Cuda capability is 3.5. 2018-04-26 13:00:19.181669: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-04-26 13:00:19.181683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917] 0 2018-04-26 13:00:19.181695: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0: N >>> print(sess.run(hello)) b'Hello, World!'
- Supported cards:
https://developer.nvidia.com/cuda-gpus