Wymagania nvidia: cuda-installation-guide-linux oprogramowanie sprzęt: CPU i GPU
Skrócona wersja Wybieramy sterownik odpowiedni dla naszej karty graficznej ( GPU) nvidia: Version: 470.199.02 dla Nvidia Geoforce GTX 770 na podstawie GPU - Compute compatybility: GeoForce GTX 770 = 3.0
Sprzęt
Możemy użyć sysinfo
sysinfo
lub lshw:
sudo lshw
CPU Sprawdzamy czy mamy odpowiedni CPU procesor (x86 CPUs z SSE3):OpenCL Hardware-support by Vincent HindriksenDecember 29, 2011
cat /proc/cpuinfo | grep sse3
GPU
Sprawdzamy czy mamy odpowiedni GPU:OpenCl Conformant Products
Z konsoli ( CLI):linuxconfig : how-to-check-nvidia-driver-version-on-your-linux-system lspci | grep VGA sudo lshw -C display nvidia-smi grep "X Driver" /var/log/Xorg.0.log modinfo /usr/lib/modules/$(uname -r)/kernel/drivers/video/nvidia.ko | grep ^version
GUI NVIDIA X server settings/ System information/NVIDIA Driver Version: 470.199.02
Wybieramy sterownik odpowiedni dla naszej karty graficznej ( GPU) nvidia: Version: 470.199.02 dla Nvidia Geoforce GTX 770
Oprogramowanie
Z punktu widzenia programisty oprogramowanie OpenCL składa się z:Install OpenCL on Debian, Ubuntu and Mint orderly sterownik GPU z wsparciem dla OpenCL (aktualnie wszystkie sterowniki wspierają OpenCl) pliki nagłówkowe OpenCL odpowiednie dla sprzętu biblioteki (potrzebne gdy używamy -lOpenCL) libOpenCL.so = ICD Loader An installable client driver = icd
Pakiety : icd-loader : nvidia-libopencl1 icd : nvidia-opencl-icd headers: opencl-headers
You need to have a SDK which provides interface to CPU. nVidia does not, AMD and Intel's SDKs do; in my case the one from Intel is significantly (something like 10x) faster, which might due to bad programming on my part however.
You don't need the SDK for programs to run, just the runtime. In Linux, each vendor installs a file in /etc/OpenCL/vendors/*.icd, which contains path of the runtime library to use. That is scanned by the OpenCL runtime you link to (libOpenCL.so), which then calls each of the vendor's libs when querying for devices on that particular platform.
In Linux, the GPU drivers install OpenCL runtime automatically, the Intel runtime is likely to be downloadable separately from the SDK, but is part of the SDK as well, of course.
answered Mar 28 '12 at 19:55 eudoxosStackoverflow.com: Need to install opencl for CPU and GPU platforms?
SDK Wszystkie te składniki powinien zawierać OpenCl SDK. Instalacje SDK powinna rozwiązywać problem z instalacją OpenCl. W praktyce jest to bardziej skomplikowane.
Podziałstackoverflow questions: hat-is-a-example-of-a-target-platform-in-opencl wg platformy sprzętowej (Intel, Nvidia, AMD) wg licencji własnościowe: Intel SDK OpenSource BeignetBeignet Portable Computing Language Clover clover NeoNeo
Istnieją SDK: dla GPU firmy AMD/ATI wybieramy AMD APP SDK (wcześniej znany jako AMD Stream SDK)AMD APP SDK, interfejs to CPU dla GPU firmy Intel (np. GPU Intel HD Graphics 4000 wbudowany w procesor CPU i7-3770K)Intel® SDK for OpenCL, interfejs to CPU dla GPU firmy Nvidia wybieramy CUDA toolkit CUDA Toolkit, który obsługuje również OpenCLUnable to find Nvidia OpenCL SDK, nie ma interfejsu do CPUStackoverflow: Need to install opencl for CPU and GPU platforms? Nie ma SDK KhronosHow to obtain OpenCL SDK?
OS
Wybieramy taką wersję OS dla której jest dostępny CUDA Toolkit. Aktualnie np. 64-bit Ubuntu 12.04 LTSHands On OpenCL, by Simon McIntosh-Smith and Tom Deakin
Sterowniki GPU Instalujemy sterowniki odpowiednie do posiadanego sprzętu Nvidia Opis:
Blacklist the open source driver (IMPORTANT) sudo nano /etc/modprobe.d/blacklist.conf Add the line: blacklist nouveau Install some dependencies sudo apt-get install build-essential linux-header-generic opencl-headers Download the NVIDIA driver from their website and unpack the download In a virtual terminal (Ctrl+Alt+F1), stop the windows manager sudo service lightdm stop Give the script run permissions then run it chmod +x *.run sudo ./*.run The pre-install test will fail – this is OK! Say yes to DKMS, 32-bit GL libraries and to update your X config Reboot! Opis Opis instalacji na UbuntuInstalacja OpenCl na UbuntuNVIDIA CUDA Getting Started Guide for LinuxA Tutorial for using OpenCL in ImageJ
Problemy: /var/log/cuda-installer.log /var/log/nvidia-installer.log
Pliki nagłówkowe
Instalacja plików nagłówkowych w Ubuntu 13.04:
sudo apt-get install ocl-icd-opencl-dev
Pliki nagłówkowe Khronos (wspólne dla wszystkich SDK): lista ze strony Khronos OpenCL Registry pakiet Ubuntu “khronos-opencl-headers” package in Ubuntu
Wszystkie pliki nagłówkowe powinny być w katalogu CL/
Plik opencl.h dołącza (ang. includes) pozostałe pliki nagłówkowe.
Pakiety : opencl-headers
Biblioteki podstawowe
OpenCL.lib
Dla Nvidia i 64 bitowego systemu:
echo "/usr/local/cuda/lib64" > /etc/ld.so.conf.d/opencl-vendor-nvidia.conf echo "/usr/local/cuda/lib" >> /etc/ld.so.conf.d/opencl-vendor-nvidia.conf
i
ldconfig
dodatkowe
easyCL EasyCL w Github dynamic scheduling (gpu cpu) OpenCL: Running CPU/GPU multiple devices StarPU: A Unified Runtime System for Heterogeneous Multicore ArchitecturesStarPU: A Unified Runtime System for Heterogeneous Multicore Architectures
libOpenCL.so
Biblioteka współdzielona (rozszerzenie so) libOpenCL.so = ICD loader
Lokalizacja biblioteki zależy od rodzaju zainstalowanego SDK The OpenCL Programming Book - pierwszy program
locate libOpenCL.so
Przykładowy wynik:
/usr/lib/libOpenCL.so /usr/lib/nvidia-current/libOpenCL.so /usr/lib/nvidia-current/libOpenCL.so.1 /usr/lib/nvidia-current/libOpenCL.so.1.0 /usr/lib/nvidia-current/libOpenCL.so.1.0.0 /usr/lib32/libOpenCL.so /usr/lib32/nvidia-current/libOpenCL.so /usr/lib32/nvidia-current/libOpenCL.so.1 /usr/lib32/nvidia-current/libOpenCL.so.1.0 /usr/lib32/nvidia-current/libOpenCL.so.1.0.0
Używamy tylko jednego loadera (najlepiej Khronos, nawet jeśli mamy Nvidia!):
sudo ln -s /usr/lib64/libOpenCL.so /usr/lib64/libOpenCL.so.1.2 sudo ln -s /usr/lib/libOpenCL.so /usr/lib/libOpenCL.so.1.2
Linki: OpenCL ICD Loader OpenCL ICD Loader
icd
(do przetłumaczenia) "ICD" to plik w systemach Linux ze ścieżką i nazwą pliku biblioteki .so.
"OpenCL ICD: Installable Client Driver. Vendor-provided component that interfaces between the OpenCL library and the actual hardware. Example: NVIDIA CUDA also offers an OpenCL ICD, allowing OpenCL access to its GPUs. AMD offers an OpenCL ICD as part of its Accelerated Parallel Processing (APP) (formerly known as ATI Stream) solution, allowing OpenCL access to AMD and ATI video cards as well as x86 and x86-64 CPUs Intel offers an OpenCL ICD for its CPUs and for the Sandy Bridge (integrated CPU/GPU) Khronos cl_khr_icd.txt
Multiple ICDs can coexist on the same machine, the programmer can choose which one(s) to use."OpenCL by Giuseppe Bilotta, Eugenio Rustico, Alexis Hérault
Pliki icd powinny być w katalogu: /etc/OpenCL/vendor/
Lista zainstalowanych platform OpenCL:PClab : Akceleracja GPU w praktyce – OpenCL. Drzemiące megaflopy. Mateusz Brzostek, Poniedziałek, 21 stycznia 2013 ls /etc/OpenCL/vendors
przykładowy wynik:
nvidia.icd
dodatkowe programy
przykłady OpenCl wykorzystują Glut dla tworzenia GUI. Zainstaluj glut3-dev.OpenCL Ubuntu Install Guide Oct24 by Brandon A. Mayer gcc w wersji >= 4.7 pyopencl, numpy
IDE OpenCL Studio OpenCL studio Eclipse User Manual for Intel® SDK for OpenCL™ ApplicationsOpenCL on LinuxOpenCL experiments
toolkit
nvcc -V
Command 'nvcc' not found, but can be installed with: sudo apt install nvidia-cuda-toolkit
Test
apt-cache search opencl
clinfo
sudo apt-get install clinfo
sudo clinfo
Przykładowy wynik:
Number of platforms 1 Platform Name NVIDIA CUDA Platform Vendor NVIDIA Corporation Platform Version OpenCL 1.2 CUDA 8.0.20 Platform Profile FULL_PROFILE Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts Platform Extensions function suffix NV
Platform Name NVIDIA CUDA Number of devices 1 Device Name GeForce GTX 770 Device Vendor NVIDIA Corporation Device Vendor ID 0x10de Device Version OpenCL 1.2 CUDA Driver Version 361.42 Device OpenCL C Version OpenCL C 1.2 Device Type GPU Device Profile FULL_PROFILE Device Topology (NV) PCI-E, 01:00.0 Max compute units 8 Max clock frequency 1189MHz Compute Capability (NV) 3.0 Device Partition (core) Max number of sub-devices 1 Supported partition types None Max work item dimensions 3 Max work item sizes 1024x1024x64 Max work group size 1024 Preferred work group size multiple 32 Warp size (NV) 32 Preferred / native vector sizes char 1 / 1 short 1 / 1 int 1 / 1 long 1 / 1 half 0 / 0 (n/a) float 1 / 1 double 1 / 1 (cl_khr_fp64) Half-precision Floating-point support (n/a) Single-precision Floating-point support (core) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero Yes Round to infinity Yes IEEE754-2008 fused multiply-add Yes Support is emulated in software No Correctly-rounded divide and sqrt operations Yes Double-precision Floating-point support (cl_khr_fp64) Denormals Yes Infinity and NANs Yes Round to nearest Yes Round to zero Yes Round to infinity Yes IEEE754-2008 fused multiply-add Yes Support is emulated in software No Correctly-rounded divide and sqrt operations No Address bits 64, Little-Endian Global memory size 2146762752 (1.999GiB) Error Correction support No Max memory allocation 536690688 (511.8MiB) Unified memory for Host and Device No Integrated memory (NV) No Minimum alignment for any data type 128 bytes Alignment of base address 4096 bits (512 bytes) Global Memory cache type Read/Write Global Memory cache size 131072 Global Memory cache line 128 bytes Image support Yes Max number of samplers per kernel 32 Max size for 1D images from buffer 134217728 pixels Max 1D or 2D image array size 2048 images Max 2D image size 16384x16384 pixels Max 3D image size 4096x4096x4096 pixels Max number of read image args 256 Max number of write image args 16 Local memory type Local Local memory size 49152 (48KiB) Registers per block (NV) 65536 Max constant buffer size 65536 (64KiB) Max number of constant args 9 Max size of kernel argument 4352 (4.25KiB) Queue properties Out-of-order execution Yes Profiling Yes Prefer user sync for interop No Profiling timer resolution 1000ns Execution capabilities Run OpenCL kernels Yes Run native kernels No Kernel execution timeout (NV) Yes Concurrent copy and kernel execution (NV) Yes Number of async copy engines 1 printf() buffer size 1048576 (1024KiB) Built-in kernels Device Available Yes Compiler Available Yes Linker Available Yes Device Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts
NULL platform behavior clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) NVIDIA CUDA clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) Success [NV] clCreateContext(NULL, ...) [default] Success [NV] clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) No platform
ICD loader properties ICD loader Name OpenCL ICD Loader ICD loader Vendor OCL Icd free software ICD loader Version 2.2.8